“Latihan ComboBox” dengan Visual Basic 6.0
“Latihan ComboBox” yang terdapat pada eBook “Panduan Praktik Pemrograman Komputer”.
Tidak ada modifikasi yang dibuat. Hanya sekedar mencoba membuat programnya saja. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Identitas Mahasiswa"
ClientHeight = 3615
ClientLeft = 45
ClientTop = 405
ClientWidth = 4830
BeginProperty Font
Name = "Segoe UI"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3615
ScaleWidth = 4830
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 9
Top = 3240
Visible = 0 'False
Width = 4830
_ExtentX = 8520
_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 = "Tampilkan Data"
Enabled = 0 'False
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 240
TabIndex = 8
Top = 2160
Width = 4335
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 1680
Style = 2 'Dropdown List
TabIndex = 7
Top = 1500
Width = 2895
End
Begin VB.OptionButton Option1
Caption = "Perempuan"
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 3120
TabIndex = 5
Top = 840
Width = 1455
End
Begin VB.OptionButton Option1
Caption = "Laki-laki"
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 1680
TabIndex = 4
Top = 840
Width = 1215
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 1680
TabIndex = 1
Top = 240
Width = 2895
End
Begin VB.CommandButton Command1
Caption = "Keluar"
Height = 495
Index = 0
Left = 3360
TabIndex = 2
Top = 3000
Width = 1215
End
Begin VB.Line Line1
Index = 0
X1 = 240
X2 = 4560
Y1 = 2880
Y2 = 2880
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Program Studi:"
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 240
TabIndex = 6
Top = 1560
Width = 1305
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Jenis Kelamin:"
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 240
TabIndex = 3
Top = 960
Width = 1215
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Nama:"
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 840
TabIndex = 0
Top = 300
Width = 570
End
Begin VB.Line Line1
BorderColor = &H00FFFFFF&
BorderWidth = 4
Index = 1
X1 = 240
X2 = 4560
Y1 = 2880
Y2 = 2880
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Jenis_Kelamin$
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
Unload Me
Case 1:
MsgBox "Nama anda " & Text1.Text & vbCrLf & vbCrLf & _
"Anda adalah seorang " & Jenis_Kelamin & vbCrLf & _
vbCrLf & "Program studi yang diambil adalah " & _
Combo1.Text, vbInformation + vbOKOnly, "Data Anda"
Text1.Text = Empty
Dim i%
For i = 0 To 1
Option1(i).Value = False
Next
Combo1.Clear
Form_Load
Text1.SetFocus
End Select
End Sub
Private Sub Form_Load()
Combo1.AddItem "Fisika"
Combo1.AddItem "Matematika"
Combo1.AddItem "Kimia"
Combo1.AddItem "Biologi"
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 Option1_Click(Index As Integer)
Select Case Index
Case 0:
Jenis_Kelamin = Option1(Index).Caption
Case 1:
Jenis_Kelamin = Option1(Index).Caption
End Select
End Sub
Private Sub Text1_Change()
If Text1.Text = Empty Then
Command1(1).Enabled = False
Else
Command1(1).Enabled = True
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Then
Beep
KeyAscii = 0
End If
End Sub
Unduh Kode Sumber
Label: VB6
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda