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.
Baik, langkah pertama pastinya, anda semua harus membuka terlebih dahulu VB anda.
Pada gambar diatas menjelaskan bagaimana cara anda untuk membuat project baru.
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 :
Anda beri nama ”layar”.
Anda beri nama ”nomor1” s/d ”nomor0”.
Anda beri nama ”tambah”, “kurang”, “kali”, dan “bagi”.
Anda beri nama ”clear”.
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.
Setelah anda memasukkan coding tersebut dengan sesuai, maka tinggal anda jalankan software tersebut.
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.
FOLLOW @belajar.ngoding
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
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
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) :
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:
Congratulations @belajar.ngoding! You received a personal award!
Click here to view your Board
Congratulations @belajar.ngoding! You received a personal award!
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!