Latest News

Membuat kalkulator sederhana dengan Visual Basic 6.0


Berikut ini adalah langakah-langak pembuatan kalkulator sederhana menggunakan bahasa pemrograman Visual Basic 6.0.
Langkah-langkahnya:
Pertama : buat tampilan seperti berikut dengan ketentuan
Label 1 buah (hanya untuk judul saja)
Text 2 buah sebagai input nilai.
Common Button 7 buah digunakan untuk operator aritmatika dan tombol fungsi keluar.














Buka page source code, lalu tuliskan source code berikut.
Private Sub Command1_Click()
Text2.Text = Val(Text1.Text) + Val(Text2.Text)
Text1.Text = ""                                
Text1.SetFocus
End Sub

Private Sub Command2_Click()
Text2.Text = Val(Text1.Text) - Val(Text2.Text)
Text1.Text = ""                                       
Text1.SetFocus
End Sub

Private Sub Command3_Click()
Text2.Text = Val(Text1.Text) / Val(Text2.Text)
Text1.Text = ""                                  
Text1.SetFocus
End Sub

rivate Sub Command4_Click()
Text2.Text = Val(Text1.Text) * Val(Text2.Text)
Text1.Text = ""                                        
Text1.SetFocus
End Sub

rivate Sub Command5_Click()
Text2.Text = Val(Text1.Text) ^ Val(Text2.Text)         
End Sub

Private Sub Command6_Click()
Text1.Text = ""
Text2.Text = ""                         
Text3.Text = ""
End Sub

Private Sub Command7_Click()
End                                 
End Sub

Demikian program sederhana untuk membuat kalkulator sederhana.

0 komentar:

Posting Komentar