This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Kamis, 27 Agustus 2015

CARA MEMBUAT KALKULATOR MENGGUNAKAN VBNET

Buat Desain Program Sesuka  Anda atau Seperti gambar dibawah ini :
 1. Buat Button Angka 0 hingga 9 tentukan sendiri name layer button tersebut.
    -    Klik 2x pada button angka tersebut  kemudian ketik coding dibawah ini.
  
Koding Angka 0-9
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As      System.EventArgs) Handles Button7.Click
      Label2.Text = Label2.Text & "0"
Label2.Text = Label2.Text & "1"
Label2.Text = Label2.Text & "2"
Label2.Text = Label2.Text & "3"
‘Dan seterusnya


2.     Kemudian Buat Button Operator Seperti:  (+)(-)(/)(*)(^)  (Tambah, kurang, bagi, kali, dan pangkat). Tentukan sendiri name layer button tersebut diproperties.

Koding Operator

Public Class Form1

    Dim nilai As Double
    Dim aksi As String

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        nilai = Val(Label2.Text)
        Label1.Text = Label2.Text & "" & " + "
        Label2.Text = ""
        aksi = "+"
‘yang button (-,:,x,^) dan yang lainnya sama.!!!

3. Buat Button Sama Dengan. Tentukan sendiri name layer button tersebut diproperties.

Koding sama dengan (=)

Public Class Form1

Dim aksi As String

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If aksi = "+" Then
            Label2.Text = nilai + Label2.Text
        End If
        If aksi = "-" Then
            Label2.Text = nilai - Label2.Text
        End If
  If aksi = ":" Then
            Label2.Text = nilai / Label2.Text
        End If
  If aksi = "x" Then
            Label2.Text = nilai * Label2.Text
        End If
  If aksi = "^" Then
            Label2.Text = nilai ^ Label2.Text
        End If

4. Buat Button Clear Entry (CE). Tentukan sendiri name layer button tersebut diproperties.

Koding Clear Entry (CE)

Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
       
  TextBox1.Text = ""
        Label1.Text = ""
        Label2.Text = ""

 5. Button Delete (DEL)  Tentukan sendiri name layer button tersebut diproperties.

Koding DELETE(DEL)

Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
        If Label2.Text <> "" Then
            Label2.Text = ""
        End If

6. Button Delete (DEL)  Tentukan sendiri name layer button tersebut diproperties.

Koding PLUS MINUS(+/-)

Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
        Label2.Text = "- " & Label2.Text


7.  Buat Button EXIT.  Tentukan sendiri name layer button tersebut diproperties.

Koding EXIT “MESSAGES BOX”

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        pesan = MsgBox(" Apakah Anda yakin ingin keluar dari Aplikasi ini? ", MsgBoxStyle.Question + MsgBoxStyle.YesNo, " Calculator ")
        If pesan = vbYes Then
            Me.Close()
        End If
  
8.    Buat sebuah LABEL tetapi kosongkan nama text LABEL tersebut.  Dan Tambahkan Timer di Toolbox. Tentukan sendiri name layer label tersebut diproperties.
Koding RUNNING TEKS
(“Selamat Menghitung”)
Public Class Kalkulator
    Dim tulisan(2) As String
    Dim i, j As Integer

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If i.Equals(tulisan(j).Length) Then
            Me.LBLucapan.Text = " "
            If j < tulisan.Length - 1 Then
                j = j + 1
                Me.LBLucapan.Text = tulisan(j)
            Else
                j = 0
            End If
            i = 0
        End If
        LBLucapan.Text = tulisan(j).Substring(0, i)
        i = i + 1
    End Sub


Private Sub Kalkulator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tulisan(0) = " Selamat Menghitung ! "
        tulisan(1) = " Selamat Menghitung ! "
        tulisan(2) = " Selamat Menghitung ! "
        Timer1.Start(