Rabu, 05 Februari 2014

TUTORIAL PROGRAM VB MEMBUAT KALKULATOR SEDERHANA

Seperti biasa Siapin dulu bahan – bahannya ya… ^O^


From 1
Kalkulator
Toolbox
Text
Button 1
+
Button 2
-
Button 3
X
Button 4
/
Label 1
(Kosong)
Label 2
(Kosong)

Aku mendesainnya seperti ini :



Jangan lupa diatur namanya ya... :) caranya tinggal klik toolbox yg akan diatur > properties > Text



Nah, jika sudah diatur hasilnya akan jadi seperti ini :


Next.. waktunya memasukan source codenya !!!

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label2.Text = "+"
        Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Label2.Text = "-"
        Label1.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Label2.Text = "/"
        Label1.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Label2.Text = "X"
        Label1.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
    End Sub
End Class

Nh hasilnya akan jadi seperti ini :)


Selamat mencoba... semoga tutorial ini dapat membantu.. :)

Tidak ada komentar:

Posting Komentar