Ini adalah cara sederhana
untuk membuat kalkulator menggunakan VB2010
Berikut caranya:
Buatlah Form seperti contoh
gambar diatas , berikut scriptnya
Public Class
Form1
Private
Sub Form1_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
End
Sub
Private
Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles ComboBox1.SelectedIndexChanged
Form2.Show()
End
Sub
End Class
Lalu buatlah di form 2 seperti
berikut ;
Berikut scriptnya ;
Public Class
form2
Private
Sub Rbpengurangan_CheckedChanged(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Rbpengurangan.CheckedChanged
End
Sub
Private
Sub Rbperkalian_CheckedChanged(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Rbperkalian.CheckedChanged
End
Sub
End Class
Untuk Form 3;
Script ;
Public Class
Form3
Private
Sub Label2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Label2.Click
End
Sub
Private
Sub Bttnhasil_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bttnhasil.Click
If Form2.Rbperkalian.Checked = True
Then
txthasil.Text =
Val(Txt1.Text) * Val(txt2.Text)
Else
End If
Form4.Label2.Text =
txthasil.Text
Form4.Show()
End
Sub
Private
Sub Form3_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
End
Sub
Private
Sub txthasil_TextChanged(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles txthasil.TextChanged
End
Sub
End Class
Dan ini form ke empat atau
form terakhir :
Public Class
Form4
Private
Sub Label1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Label1.Click
End
Sub
Private
Sub Form4_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
End
Sub
Private
Sub Button2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button2.Click
Close()
End
Sub
Private
Sub Button1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button1.Click
Form1.Show()
End
Sub
End Class
0 komentar:
Posting Komentar