Rabu, 01 Oktober 2014

“Latihan 8 Visual Basic” dengan Visual Basic 6.0

VB6SP6_logo

“Latihan 8 Visual Basic” yang terdapat pada blog Yulis Riyadi.

Tidak banyak modifikasi yang dibuat. Hanya sekedar merubah hasil keluaran program supaya lebih terbiasa dengan logika program sebelumnya. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.

 

 

DaftarNamaSiswa

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Daftar Nama Siswa"
ClientHeight = 2295
ClientLeft = 45
ClientTop = 375
ClientWidth = 7335
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 = 2295
ScaleWidth = 7335
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 6
Top = 1920
Visible = 0 'False
Width = 7335
_ExtentX = 12938
_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 = "Keluar"
Height = 495
Index = 2
Left = 4560
TabIndex = 5
Top = 1560
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "Redim"
Height = 495
Index = 1
Left = 5880
TabIndex = 4
Top = 840
Width = 1215
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4560
TabIndex = 3
Top = 900
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Input"
Height = 495
Index = 0
Left = 5880
TabIndex = 2
Top = 240
Width = 1215
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4560
Style = 2 'Dropdown List
TabIndex = 1
Top = 320
Width = 1215
End
Begin VB.ListBox List1
Height = 1860
Left = 240
TabIndex = 0
Top = 240
Width = 4095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Nama_Siswa() As String
Dim i%

Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
Dim Nomor_Urut As Integer

No = CInt(Combo1.Text)
Nama_Siswa(No) = InputBox("Masukan Nama Siswa Nomor Urut Ke : " & No, "Mendaftarkan Nama Siswa")
If Nama_Siswa(No) <> "" Then
List1.Clear
For i = 1 To UBound(Nama_Siswa)
List1.AddItem "Nama Siswa Ke-" & i & " : " & Nama_Siswa(i)
Next
End If
Case 1:
If Not IsNumeric(Text1.Text) Then Exit Sub

Num = CInt(Text1.Text)

ReDim Preserve Nama_Siswa(1 To Num)

Combo1.Clear
List1.Clear
For i = 1 To UBound(Nama_Siswa)
Combo1.AddItem i
List1.AddItem "Nama Siswa Ke-" & i & " adalah " & Nama_Siswa(i)
Next
Combo1.ListIndex = 0
Case 2:
Dim Respon
Respon = MsgBox("Keluar program ?", _
vbQuestion + vbYesNo, _
"Perhatian")
If Respon = vbYes Then
End
End If
End Select
End Sub

Private Sub Form_Load()
ReDim Nama_Siswa(1 To 10)
For i = 1 To 10
Combo1.AddItem i
Next
Combo1.ListIndex = 0
End Sub

Private Sub Text1_KeyPress(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
Command1_Click (1)
End If
End Sub



Unduh Kode Sumber

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda