1).langkah pertama dalam membuat projek gaji karyawan adalah sebagai berikut :
buatlah label sebanyak 7 label.
rubahlah label 1 dengan mengganti nama caption menjadi gaji karyawan
rubahlah label ke 2 dengan mengganti nama caption menjadi gaji
rubahlah label ke 3 dengan mengganti nama caption menjadi kelebihan jam
rubahlah label ke 4 dengan mengganti nama caption menjadi terlambatrubahlah label ke 5 dengan mengganti nama caption menjadi hadiah
rubahlah label ke 6 dengan mengganti nama caption menjadi bonus
rubahlah label ke 7 dengan mengganti nama caption menjadi total gaji.
2).langkah kedua dalam membuat textbox :
buatlah sebanyak 5 textbox.
3).langkah tiga dalam membuat command button :
buatlah command button sebanyak 4 label.
rubahlah command button ke 1 dengan mengganti nama caption menjadi proses.
rubahlah command button ke 2 dengan mengganti nama caption menjadi exit.
rubahlah command button ke 3 dengan mengganti nama caption menjadi bersih.
rubahlah command button ke 4 dengan mengganti nama caption menjadi aktif.4).setelah pembuatan objec kita harus melakukan penngcodengan.
5).setelah itu lalu di lihat hasilnya atau tekan F5.
view code souce
Dim angka(1 To 2) As String
Dim nilai(1 To 2) As String
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
Combo1.SetFocus
Else
Command1.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13) Or KeyAscii = 13 Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub Command1_Click()
If Text1 = "" Then
Text1.SetFocus
ElseIf Text2 = "" Then
Text2.SetFocus
ElseIf Not (Combo1 = "tidak" Or Combo1 = "ya") Then
Combo1.Text = ""
Combo1.SetFocus
Else
If Text2 > 40 Then
angka(1) = Val(Text2.Text) - (40)
angka(2) = angka(1) * (25000)
Text4.Text = angka(2)
Else
Text4.Text = "0"
End If
If Combo1.Text = "tidak" Then
nilai(1) = Val(Text1.Text) * (10)
nilai(2) = nilai(1) / (100)
Text3.Text = nilai(2)
Else
Text3.Text = "0"
End If
Text5 = Val(Text1) + Val(Text3) + Val(Text4)
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Combo1.Text = ""
End Sub
Private Sub Command4_Click()
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Combo1.Enabled = True
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
End Sub
Private Sub Form_Load()
Combo1.AddItem "tidak"
Combo1.AddItem "ya"
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Combo1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
Text1.SetFocus
Else
Text2.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13) Or KeyAscii = 13 Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
Text2.SetFocus
Else
Combo1.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13) Or KeyAscii = 13 Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Dim nilai(1 To 2) As String
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
Combo1.SetFocus
Else
Command1.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13) Or KeyAscii = 13 Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub Command1_Click()
If Text1 = "" Then
Text1.SetFocus
ElseIf Text2 = "" Then
Text2.SetFocus
ElseIf Not (Combo1 = "tidak" Or Combo1 = "ya") Then
Combo1.Text = ""
Combo1.SetFocus
Else
If Text2 > 40 Then
angka(1) = Val(Text2.Text) - (40)
angka(2) = angka(1) * (25000)
Text4.Text = angka(2)
Else
Text4.Text = "0"
End If
If Combo1.Text = "tidak" Then
nilai(1) = Val(Text1.Text) * (10)
nilai(2) = nilai(1) / (100)
Text3.Text = nilai(2)
Else
Text3.Text = "0"
End If
Text5 = Val(Text1) + Val(Text3) + Val(Text4)
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Combo1.Text = ""
End Sub
Private Sub Command4_Click()
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Combo1.Enabled = True
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
End Sub
Private Sub Form_Load()
Combo1.AddItem "tidak"
Combo1.AddItem "ya"
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Combo1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
Text1.SetFocus
Else
Text2.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13) Or KeyAscii = 13 Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
Text2.SetFocus
Else
Combo1.SetFocus
End If
End If
If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13) Or KeyAscii = 13 Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
SELAMAT MENCOBA
VISUAL BASIC 6.0
0 komentar:
Posting Komentar