Erdianto

Belajar Ilmu Komputer dan Teknologi Opensource

Membuat kalkulator menggunakan VB

Posted by bemk4mpus On June - 13 - 2011

Membuat kalkulator menggunakan VB

Nie bentuk Form yang akan kita buat nantinya, yeaaaa……. Yang pastinya di buat dulu seperi Form dibawah ini seperti kalkulator cabe itu, upss,,, jadi kayak mau blik cabe nie
clipboard014
Hemmm.. cekidot langsung ja, buat seperti ini ya sobat ya..
clipboard024

    Ini tempat Code-cedo progam yang sobat nanti kerjakan…
    Masuk kan List program yang sudah saya buat di bawah ntu, n sobat tinggal Copas aja..
    clipboard033
    Kalkulator nie saya menggunakan perintah sedrhana aja n untuk memudahkan para sobat…
    Bisa juga sobat memakai cara yang lain contoh nya menggunakan Perintah Select Case dll

    Dim x, y, z As Double
    Dim tb, kr, kl, bg, pr As Boolean

    Private Sub Bagi_Click()
    bg = True
    tb = False
    kr = False
    kl = False
    pr = False
    x = Val(Text1)
    Text1 = “”
    Text1.SetFocus
    End Sub

    Private Sub C0_Click()
    Text1 = Text1 + “0″
    End Sub

    Private Sub C1_Click()
    Text1 = Text1 + “1″
    End Sub

    Private Sub C2_Click()
    Text1 = Text1 + “2″
    End Sub

    Private Sub C3_Click()
    Text1 = Text1 + “3″
    End Sub

    Private Sub C4_Click(Index As Integer)
    Text1 = Text1 + “4″
    End Sub

    Private Sub C5_Click()
    Text1 = Text1 + “5″
    End Sub

    Private Sub C6_Click()
    Text1 = Text1 + “6″
    End Sub

    Private Sub C7_Click()
    Text1 = Text1 + “7″
    End Sub

    Private Sub C8_Click()
    Text1 = Text1 + “8″
    End Sub

    Private Sub C9_Click()
    Text1 = Text1 + “9″
    End Sub

    Private Sub Command1_Click()
    Text1.Text = “”
    Text1.SetFocus
    End Sub

    Private Sub Command18_Click()

    End Sub

    Private Sub Command11_Click()

    End Sub

    Private Sub hasil_Click()
    y = Val(Text1)
    If tb Then
    z = x + y
    Else
    If kr Then
    z = x - y
    Else
    If kl Then
    z = x * y
    Else
    If bg Then
    z = x / y
    Else
    If pr Then
    z = Val(Text1) / 100
    End If
    End If
    End If
    End If
    End If
    Text1 = z

    End Sub

    Private Sub Kali_Click()
    kl = True
    tb = False
    kr = False
    bg = False
    pr = False
    x = Val(Text1)
    Text1 = “”
    Text1.SetFocus
    End Sub

    Private Sub Kurang_Click()
    kr = True
    tb = False
    kl = False
    bg = False
    pr = False
    x = Val(Text1)
    Text1 = “”
    Text1.SetFocus
    End Sub

    Private Sub Persen_Click()
    pr = True
    kr = False
    tb = False
    kl = False
    bg = False
    x = Val(Text1)
    z = Val(Text1) / 100
    End Sub

    Private Sub Plusminus_Click()
    Dim a As String
    Dim b, c As Double
    a = Left(Text1, 1)
    b = Val(Text1)
    If a = “-” Then
    c = Abs(b)
    Text1 = c
    Else
    Text1.Text = “-” + Text1
    End If
    End Sub

    Private Sub Tambah_Click()
    tb = True
    kr = False
    bg = False
    kl = False
    x = Val(Text1)
    Text1 = “”
    Text1.SetFocus

    End Sub

    Nah lau dah d Copas n dah di tempatkan dengan benar List Program nya pasti jalan, dan sobat dah punya Calkulator sederhana. Gak pala blik Calkulator d Toko-toko dong kan mahal….

    Dan ingat untuk para sobat Blog saya, setiap List Program yang ada End Sub berarti akhir dari Program tersebut dan harus mengklik tombol Cammanbottom selanjutnya, pasti agan tau itu saya yakin..

    Good Luck !


    Jadilah orang pertama yang menyukai tulisan ini
    Apakah anda menyukai tulisan ini ?
    Share and Enjoy:
    • Facebook
    • Google
    • Print this article!
    • TwitThis
    • Furl
    • Live

    Comments are closed.

    About Me

    There is something about me..

    Twitter

      Photos

      Activate the Flickrss plugin to see the image thumbnails!