Option Explicit
Dim bar
Dim Totalbar As Integer
Dim tmpnama() As String
Dim tmpalamat() As String
Dim tmpkelas() As String
Dim tmplahir() As String
Private Sub Command6_Click()
Dim pj As Integer
Dim i
pj = Len(Text6.Text)
For i = 1 To Totalbar
If Mid$(UCase$(tmpnama(i)), 1, pj) = UCase$(Text6.Text) Then
Debug.Print "Ketemu"
Exit For
End If
Next i
LihatRec (i)
End Sub
Private Sub Form_Load() ' cari data
Me.Top = FormUtama.Top
Me.Left = FormUtama.Width + FormUtama.Left + 10
Totalbar = 1
ReDim tmpnama(Totalbar)
ReDim tmpalamat(Totalbar)
ReDim tmpkelas(Totalbar)
ReDim tmplahir(Totalbar)
bar = 1
Open "d:\datasiswa.txt" For Input As #1
Do While Not EOF(1)
Input #1, tmpnama(bar), tmpkelas(bar), tmpalamat(bar), tmplahir(bar)
Debug.Print bar
bar = bar + 1
If bar > Totalbar Then
ReDim Preserve tmpnama(bar)
ReDim Preserve tmpalamat(bar)
ReDim Preserve tmpkelas(bar)
ReDim Preserve tmplahir(bar)
End If
Loop
Totalbar = bar - 1
Close #1
LihatRec (Totalbar)
Debug.Print UBound(tmpnama)
End Sub
Sub LihatRec(bar As Integer)
Text1.Text = tmpnama(bar)
Text2.Text = tmpkelas(bar)
Text3.Text = tmpalamat(bar)
Text4.Text = tmplahir(bar)
Text5.Text = bar
End Sub
Private Sub CommandSebelum_Click(Index As Integer)
bar = bar - 1
If bar <= 1 Then bar = 1
LihatRec (bar)
End Sub
Private Sub CommandSelanjutnya_Click(Index As Integer)
bar = bar + 1
If bar >= Totalbar Then bar = Totalbar
LihatRec (bar)
End Sub
Private Sub Text5_Change()
LihatRec (Val(Text5.Text))
End Sub
Private Sub Text6_Change() 'advance search
Dim pj As Integer
Dim i
pj = Len(Text6.Text)
For i = 1 To Totalbar
If Mid$(UCase$(tmpnama(i)), 1, pj) = UCase$(Text6.Text) Then
Debug.Print "Ketemu"
Exit For
End If
Next i
LihatRec (i)
End Sub