Jumat, 03 Juni 2016

Contoh program Array data pegawai

Berikut contoh program array untuk mengisi data pegawai yang dibuat dengan Visual Basic

Sintaks :
Dim NamaPekerja() As String

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Form_Load()
    Dim i As Integer
    ReDim NamaPekerja(1 To 5)
    For i = 1 To 5
        Combo1.AddItem i
    Next i
    Combo1.ListIndex = 0
    Text1.Text = 5
End Sub

Private Sub Command1_Click()
    Dim no As Integer, i As Integer
   
    no = CInt(Combo1.Text)
    NamaPekerja(no) = InputBox("Tuliskan nama pekerja no : " & no, "Input Nama Pekerja")
    If NamaPekerja(no) <> "" Then
        List1.Clear
        For i = 1 To UBound(NamaPekerja)
            List1.AddItem "NamaPekerja(" & i & ")=" & NamaPekerja(i)
        Next i
    End If
End Sub

Private Sub Command2_Click()
    Dim num As Integer, i As Integer
    If Not IsNumeric(Text1.Text) Then Exit Sub
    num = CInt(Text1.Text)
    ReDim NamaPekerja(1 To num)
    Combo1.Clear
    List1.Clear
    For i = 1 To UBound(NamaPekerja)
        Combo1.AddItem i
        List1.AddItem "NamaPekerja(" & i & ")=" & NamaPekerja(i)
    Next i
    Combo1.ListIndex = 0
End Sub




0 komentar:

Posting Komentar