Sabtu, 04 Oktober 2014

“Operator Visual Basic” dengan Visual Basic 6.0

VB6SP6_logo

Percontohan “Operator Visual Basic” yang terdapat pada blog “Ketik Visual Basic!”.

Tidak ada modifikasi yang dibuat. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.

 

 

 

OperatorVB

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Aplikasi Operator"
ClientHeight = 5895
ClientLeft = 45
ClientTop = 405
ClientWidth = 4455
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5895
ScaleWidth = 4455
StartUpPosition = 2 'CenterScreen
Begin VB.OptionButton Option1
Caption = "*"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 6
Left = 480
TabIndex = 9
Top = 3000
Width = 735
End
Begin VB.OptionButton Option1
Caption = "/"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 7
Left = 480
TabIndex = 10
Top = 3600
Width = 735
End
Begin VB.OptionButton Option1
Caption = "+"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 8
Left = 1360
TabIndex = 11
Top = 3000
Width = 735
End
Begin VB.OptionButton Option1
Caption = "-"
BeginProperty Font
Name = "Segoe UI"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 9
Left = 1360
TabIndex = 12
Top = 3600
Width = 735
End
Begin VB.OptionButton Option1
Caption = "\"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 10
Left = 2200
TabIndex = 13
Top = 3000
Width = 735
End
Begin VB.OptionButton Option1
Caption = "Mod"
Height = 495
Index = 11
Left = 2200
TabIndex = 14
Top = 3600
Width = 735
End
Begin VB.OptionButton Option1
Caption = "^"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 12
Left = 3120
TabIndex = 16
Top = 3600
Width = 735
End
Begin VB.OptionButton Option1
Caption = "&&"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 13
Left = 3120
TabIndex = 15
Top = 3000
Width = 735
End
Begin VB.OptionButton Option1
Caption = "<>"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 5
Left = 3120
TabIndex = 8
Top = 1920
Width = 735
End
Begin VB.OptionButton Option1
Caption = "="
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 4
Left = 3120
TabIndex = 21
Top = 1320
Width = 735
End
Begin VB.OptionButton Option1
Caption = "<="
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 3
Left = 1800
TabIndex = 7
Top = 1920
Width = 735
End
Begin VB.OptionButton Option1
Caption = ">="
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 2
Left = 1800
TabIndex = 6
Top = 1320
Width = 735
End
Begin VB.OptionButton Option1
Caption = "<"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 480
TabIndex = 5
Top = 1920
Width = 735
End
Begin VB.OptionButton Option1
Caption = ">"
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 480
TabIndex = 4
Top = 1320
Width = 735
End
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 22
Top = 5520
Visible = 0 'False
Width = 4455
_ExtentX = 7858
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton Command1
Caption = "Hasil"
Height = 495
Index = 1
Left = 2520
TabIndex = 19
Top = 4500
Width = 1695
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 2
Left = 240
Locked = -1 'True
TabIndex = 18
TabStop = 0 'False
Top = 4605
Width = 2055
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Index = 1
Left = 2400
TabIndex = 3
Top = 420
Width = 1815
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 240
TabIndex = 1
Top = 420
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "Keluar"
Height = 495
Index = 0
Left = 3000
TabIndex = 20
Top = 5280
Width = 1215
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Operasi Aritmatika:"
Height = 255
Index = 1
Left = 240
TabIndex = 24
Top = 2640
Width = 1665
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Operasi Perbandingan:"
Height = 255
Index = 0
Left = 240
TabIndex = 23
Top = 960
Width = 2010
End
Begin VB.Line Line1
Index = 0
X1 = 240
X2 = 4200
Y1 = 5160
Y2 = 5160
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Hasil:"
Height = 255
Index = 2
Left = 240
TabIndex = 17
Top = 4275
Width = 465
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Var Y:"
Height = 255
Index = 1
Left = 2400
TabIndex = 2
Top = 120
Width = 510
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Var X:"
Height = 255
Index = 0
Left = 240
TabIndex = 0
Top = 120
Width = 525
End
Begin VB.Line Line1
BorderColor = &H00FFFFFF&
BorderWidth = 4
Index = 1
X1 = 240
X2 = 4200
Y1 = 5160
Y2 = 5160
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
Unload Me
Case 1:
Dim Var1%, Var2%, Hasil%
Var1 = Val(Text1(0).Text)
Var2 = Val(Text1(Index).Text)

If Option1(0).Value = True Then
Hasil = Var1 > Var2
Text1(2).Text = Format(Hasil, "TRUE/FALSE")
End If

If Option1(1).Value = True Then
Hasil = Var1 < Var2
Text1(2).Text = Format(Hasil, "TRUE/FALSE")
End If

If Option1(2).Value = True Then
Hasil = Var1 >= Var2
Text1(2).Text = Format(Hasil, "TRUE/FALSE")
End If

If Option1(3).Value = True Then
Hasil = Var1 <= Var2
Text1(2).Text = Format(Hasil, "TRUE/FALSE")
End If

If Option1(4).Value = True Then
Hasil = Var1 = Var2
Text1(2).Text = Format(Hasil, "TRUE/FALSE")
End If

If Option1(5).Value = True Then
Hasil = Var1 <> Var2
Text1(2).Text = Format(Hasil, "TRUE/FALSE")
End If

If Option1(6).Value = True Then
Hasil = Var1 * Var2
Text1(2).Text = Hasil
End If

If Option1(7).Value = True Then
Hasil = Var1 / Var2
Text1(2).Text = Hasil
End If

If Option1(8).Value = True Then
Hasil = Var1 + Var2
Text1(2).Text = Hasil
End If

If Option1(9).Value = True Then
Hasil = Var1 - Var2
Text1(2).Text = Hasil
End If

If Option1(10).Value = True Then
Hasil = Var1 \ Var2
Text1(2).Text = Hasil
End If

If Option1(11).Value = True Then
Hasil = Var1 Mod Var2
Text1(2).Text = Hasil
End If

If Option1(12).Value = True Then
Hasil = Var1 ^ Var2
Text1(2).Text = Hasil
End If

If Option1(13).Value = True Then
Hasil = Var1 & Var2
Text1(2).Text = Hasil
End If
End Select
End Sub

Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Keluar program ?", vbQuestion + vbYesNo, "Perhatian") = vbNo Then
Cancel = 1
End If
End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _
KeyAscii = vbKeyBack Or KeyAscii = vbKeyReturn) Then
Beep
KeyAscii = 0
End If

If (KeyAscii = 13) Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub


Unduh Kode Sumber

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda