HOW TO CREATE CALCULATOR IN VISUAL BASIC 2010 Expert

in tutorial •  7 years ago 

ASSALAMU’ALAIKUM . WR . WB

Selamat malam para steemian/pembaca dimana pun anda berada, semoga selalu diberikan kesehatan dan rezeki yang berlimpah. Setelah sekitar lebih kurang seminggu saya tidak membuat postingan dikarenaka kesibukan akan satu dua hal sebagaimana kesibukan mahasiswa pada umumnya. Pada malam ini saya akan mencoba memberikan sedikit tutorial tentang membuat program sederhana menggunakan Visual Basic.

Sebeum saya melanjutkan ketutorialnya, saya akan sedikit membahas tentang apa ituVisual Basic. Visual Basic ini masi bernaung kepada microsoft, sering disebut dengan VB, yaitu singkatan dari Visual Basic. VB merupakan sebuah bahasa pemograman Integrated Development Environment (IDE) digunakan untuk membuat software berbasis SO Microsoft Windows dengan menggunakan model pemograman (COM). Naah, jadi si VB ini bahasa pemograman untuk membuat sebuah software yang hanya bisa dipakai pada Sistem Operasi Windows saja guys.

Baik saya rasa cukup untuk intermezo tentang VB, untuk lebih jelasnya, agan-agan bisa googling pada Mbah Google. Naah jadi tutorial yang ingin saya bagikan ini adalah, Cara Membuat Calculator. Disini saya menggunakan Visual Basic 2010 Expert. Anda semua bisa menggunakan VB jenis apa saja.

image

Baik, langkah pertama pastinya, anda semua harus membuka terlebih dahulu VB anda.


image

Pada gambar diatas menjelaskan bagaimana cara anda untuk membuat project baru.


image

Disini saya menganggap bahwa anda semua sdah memahami bagaimana caranya membuat Text Box, Button, Dan lain-lain. Coba lah anda desine lembar project anda persis seperti ini, dengan ketentuan :

image

Anda beri nama ”layar”.


image

Anda beri nama ”nomor1” s/d ”nomor0”.


image

Anda beri nama ”tambah”, “kurang”, “kali”, dan “bagi”.


image

Anda beri nama ”clear”.


image

Anda beri nama ”titik” dan ”jumlah”.


Setelah anda membuat sedemikian rupa, anda bisa mengcopy coding berikut.

Public Class Form1

Dim Firstnum As Decimal
Dim Secondnum As Decimal
Dim Operations As Integer
Dim Operator_Selector As Boolean = False

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub nomor1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor1.Click
    If layar.Text <> "0" Then
        layar.Text += "1"
    Else
        layar.Text = "1"
    End If
End Sub

Private Sub nomor2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor2.Click
    If layar.Text <> "0" Then
        layar.Text += "2"
    Else
        layar.Text = "2"
    End If
End Sub

Private Sub nomor3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor3.Click
    If layar.Text <> "0" Then
        layar.Text += "3"
    Else
        layar.Text = "3"
    End If
End Sub

Private Sub nomor4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor4.Click
    If layar.Text <> "0" Then
        layar.Text += "4"
    Else
        layar.Text = "4"
    End If
End Sub

Private Sub nomor5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor5.Click
    If layar.Text <> "0" Then
        layar.Text += "5"
    Else
        layar.Text = "5"
    End If
End Sub

Private Sub nomor6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor6.Click
    If layar.Text <> "0" Then
        layar.Text += "6"
    Else
        layar.Text = "6"
    End If
End Sub

Private Sub nomor7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor7.Click
    If layar.Text <> "0" Then
        layar.Text += "7"
    Else
        layar.Text = "7"
    End If
End Sub

Private Sub nomor8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor8.Click
    If layar.Text <> "0" Then
        layar.Text += "8"
    Else
        layar.Text = "8"
    End If
End Sub

Private Sub nomor9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor9.Click
    If layar.Text <> "0" Then
        layar.Text += "9"
    Else
        layar.Text = "9"
    End If
End Sub

Private Sub nomo0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nomor0.Click, nomo0.Click
    If layar.Text <> "0" Then
        layar.Text += "0"
    End If
End Sub

Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click
    layar.Text = "0"
End Sub

Private Sub titik_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles titik.Click
    If Not (layar.Text.Contains(".")) Then
        layar.Text += "."
    End If
End Sub

Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
    Firstnum = layar.Text
    layar.Text = "0"
    Operator_Selector = True
    Operations = 1 ' = +
End Sub

Private Sub kurang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kurang.Click
    Firstnum = layar.Text
    layar.Text = "0"
    Operator_Selector = True
    Operations = 2 ' = -
End Sub

Private Sub kali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kali.Click
    Firstnum = layar.Text
    layar.Text = "0"
    Operator_Selector = True
    Operations = 3 ' = *
End Sub

Private Sub bagi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bagi.Click
    Firstnum = layar.Text
    layar.Text = "0"
    Operator_Selector = True
    Operations = 4 ' = /
End Sub

Private Sub jumlah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah.Click

    If Operator_Selector = True Then
        Secondnum = layar.Text
        If Operations = 1 Then
            layar.Text = Firstnum + Secondnum
        ElseIf Operations = 2 Then
            layar.Text = Firstnum - Secondnum
        ElseIf Operations = 3 Then
            layar.Text = Firstnum * Secondnum
        ElseIf Secondnum = 0 Then
            layar.Text = "Error!"
        Else
            layar.Text = Firstnum / Secondnum
        End If
    End If
    Operator_Selector = False
End Sub

End Class


Bisa anda lihat juga pada gambar brikut ini.

image

image

image

image


Setelah anda memasukkan coding tersebut dengan sesuai, maka tinggal anda jalankan software tersebut.

image


image

Pada gambar diatas adalah tampilan setelah saya menjalankan software. Sebagai contoh saya membagi 2018 : 19. Hasilnya seperti pada gambar diatas.


Nah sekian dulu postingan saya pada malam hari ini, semoga kedepannya saya bisa memprioritaskan untuk memuat tutorial – tutorial lainnya lagi. Terimakasih telah membaca postingan saya, dan jika ada kekurangan atau kesalahan pada postingan ini bisa anda koreksi dengan mengomentari aritkel iini.


image


FOLLOW @belajar.ngoding

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @belajar.ngoding! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Hello, as a member of @steemdunk you have received a free courtesy boost! Steemdunk is an automated curation platform that is easy to use and built for the community. Join us at https://steemdunk.xyz

Upvote this comment to support the bot and increase your future rewards!

Congratulations @belajar.ngoding! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Do not miss the last announcement from @steemitboard!

Congratulations @belajar.ngoding! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 900 upvotes. Your next target is to reach 1000 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Meet the Steemians Contest - Special attendees revealed
Meet the Steemians Contest - Intermediate results

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @belajar.ngoding! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @belajar.ngoding! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!