Nama : Oktavio Putra Yuza
Kelas : 1 EB 01
NPM: 24219966
Implementasi Tipe Data, Variabel, Konstanta, dan Operator dalam Visual Basic
1. Membuat Program sederhana
Object
|
Property
|
Value
|
Text1
|
Caption
| |
Command1
|
Caption
|
1
|
Command2
|
Caption
|
2
|
Command3
|
Caption
|
3
|
Command4
|
Caption
|
4
|
Command5
|
Caption
|
5
|
Command6
|
Caption
|
6
|
Command7
|
Caption
|
7
|
Command8
|
Caption
|
8
|
Command9
|
Caption
|
9
|
Command10
|
Caption
|
.
|
Command11
|
Caption
|
0
|
Command12
|
Caption
|
=
|
Command13
|
Caption
|
x
|
Command14
|
Caption
|
-
|
Command15
|
Caption
|
+
|
Command16
| Caption |
/
|
Command17
|
Caption
|
C
|
Command18
|
Caption
|
E
|
Form1
| Caption | Kalkulator |
RUMUS:
Dim op, fn As Integer
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & 1
End Sub
Private Sub Command10_Click(Index As Integer)
Text1.Text = Text1.Text & "."
End Sub
Private Sub Command11_Click(Index As Integer)
Text1.Text = Text1.Text & 0
End Sub
Private Sub Command12_Click(Index As Integer)
If op = 1 Then
Text1.Text = Val(fn) + Val(Text1.Text)
ElseIf op = 2 Then
Text1.Text = Val(fn) - Val(Text1.Text)
ElseIf op = 3 Then
Text1.Text = Val(fn) * Val(Text1.Text)
ElseIf op = 4 Then
Text1.Text = Val(fn) / Val(Text1.Text)
End If
End Sub
Private Sub Command13_Click(Index As Integer)
op = 3
fn = Text1.Text
Text1.Text = ""
End Sub
Private Sub Command14_Click(Index As Integer)
op = 2
fn = Text1.Text
Text1.Text = ""
End Sub
Private Sub Command15_Click(Index As Integer)
op = 1
fn = Text1.Text
Text1.Text = ""
End Sub
Private Sub Command16_Click(Index As Integer)
op = 4
fn = Text1.Text
Text1.Text = ""
End Sub
Private Sub Command17_Click(Index As Integer)
Text1.Text = ""
End Sub
Private Sub Command18_Click(Index As Integer)
Unload Me
End Sub
Private Sub Command2_Click(Index As Integer)
Text1.Text = Text1.Text & 2
End Sub
Private Sub Command3_Click(Index As Integer)
Text1.Text = Text1.Text & 3
End Sub
Private Sub Command4_Click(Index As Integer)
Text1.Text = Text1.Text & 4
End Sub
Private Sub Command5_Click(Index As Integer)
Text1.Text = Text1.Text & 5
End Sub
Private Sub Command6_Click(Index As Integer)
Text1.Text = Text1.Text & 6
End Sub
Private Sub Command7_Click(Index As Integer)
Text1.Text = Text1.Text & 7
End Sub
Private Sub Command8_Click(Index As Integer)
Text1.Text = Text1.Text & 8
End Sub
Private Sub Command9_Click(Index As Integer)
Text1.Text = Text1.Text & 9
End Sub
Cara run program nya:
Setelah coding/kode program sudah dimasukkan ke dalam Command, setelah itu dijalankan programnya. Misal isi angka 1 di text lalu klik command kurang (-) 0 (nol) lalu klik command sama dengan (=) hasilnya adalah 1. Program ini dibuat untuk untuk menghitung dari perhitungan sederhana penjumlahan, pengurangan, perkalian dan pembagian.
Komentar
Posting Komentar