Buka program VB, kemudian buat project dengan formasi tool dan properties seperti gambar.
Setelah selesai, masukkan kode berikut ke dalam jendela kode program tersebut.
Private Sub Command1_Click()
Dim A, B, C, D As Integer
A = Val(Text1.Text)
B = Val(Text2.Text)
C = Val(Text3.Text)
D = Val(Text4.Text)
If A > B And A > C And A > D Then
Text6.Text = A
ElseIf B > C And B > D Then
Text6.Text = B
ElseIf C > D Then
Text6.Text = C
Else
Text6.Text = D
End If
End Sub
Private Sub Command2_Click()
Dim A, B, C, D As Integer
A = Val(Text1.Text)
B = Val(Text2.Text)
C = Val(Text3.Text)
D = Val(Text4.Text)
If A < B And A < C And A < D Then
Text5.Text = A
ElseIf B < C And B < D Then
Text5.Text = B
ElseIf C < D Then
Text5.Text = C
Else
Text5.Text = D
End If
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub Command4_Click()
End
End Sub
Kemudian, aktifkan program ini dengan menekan tombol "start" di toolbar sehingga muncul layar seperti gambar di bawah ini.
![]() | ||
Tampilan program setelah digit dimasukkan dan setelah menekan tombol Check Up dan Check Down |
Tidak ada komentar:
Posting Komentar