30 September 2015

Cara Membuat Program Operator Test dengan Visual Basic 6.0

Kali ini saya ingin membagikan tentang Cara Membuat Program Operator Test dengan Visual Basic 6.0


Download Program Operator Test Visual Basic 6.0

1. Buka Program Visual Basic 6.0



2. Desain Form seperti ini



3. Ubah Property

Form1-Caption-Operator Test
Label1-Caption-Variabel 1
Label2-Caption-Variabel 2 
Text1-Text-<Kosong>
Text2-Text-<Kosong>
Frame1-Caption-Op Aritmatika
Option1-Caption- +
Option2-Caption- -

Option3-Caption- *
Option4-Caption- /
Option5-Caption- &
Frame2-Caption-Op Perbandingan
Option6-Caption- >
Option7-Caption- <
Option8-Caption- =
Option9-Caption- <>
Option10-Caption- >=
Option11-Caption- <=
Frame3-Caption-Op Logika
Option12-Caption-Not
Option13-Caption-Or
Option14-Caption-And
Label3-Caption-<Kosong> 
         
4. Copy code berikut lalu klik View Code dan pastekan

Dim varl As Single, var2 As Single
Dim hasil As Single

Private Sub Form_Load()
    Text1.Text = ""
    Text2.Text = ""
    Label3.Caption = ""
End Sub

Private Sub Option1_Click()
    varl = Text1.Text
    var2 = Text2.Text
    hasil = var1 + var2
    Label3.Caption = hasil
End Sub

Private Sub Option2_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = var1 - var2
    Label3.Caption = hasil
End Sub

Private Sub Option3_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = var1 * var2
    Label3.Caption = hasil
End Sub

Private Sub Option4_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = var1 / var2
    Label3.Caption = hasil
End Sub

Private Sub Option5_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = var1 & var2
    Label3.Caption = hasil
End Sub

Private Sub Option6_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = (var1 > var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option7_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = (var1 < var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option8_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = (var1 = var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option9_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = (var1 <> var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub
Private Sub Option10_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = (var1 <> var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option11_Click()
    var1 = Text1.Text
    var2 = Text2.Text
    hasil = (var1 <= var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option12_Click()
    var1 = IIf(Text1.Text = "True", -1, 0)
    hasil = Not (var1)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option13_Click()
    var1 = IIf(Text1.Text = "True", -1, 0)
    var2 = IIf(Text2.Text = "True", -1, 0)
    hasil = (var1 Or var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

Private Sub Option14_Click()
    var1 = IIf(Text1.Text = "True", -1, 0)
    var2 = IIf(Text2.Text = "True", -1, 0)
    hasil = (var1 And var2)
    Label3.Caption = Format(hasil, "True/False")
End Sub

 

5. Jalankan Program dengan menekan F5, maka tampilannya akan seperti ini



Download Program Operator Test Visual Basic 6.0
Selamat Mencoba...!!!

No comments: