Private aa(15) As Integer
Private Conn As New ADODB.Connection
Private Rs As New ADODB.Recordset
Private Sub Command1_Click()
dim i as integer
For i = 1 To 15
If Rs.BOF Then
Rs.MoveFirst
ElseIf Rs.EOF Then
Rs.MoveLast
Else
Rs.Find "ID=" & aa(i)
text1.Text = Rs.Fields("tk_st").Value
Conn.Execute " update yanyu_l1 set tb1_st='" & LCase(Text1(1).Text) & "' where tb1_id= " & i & " "
End If
Next i
End Sub
Public Function rand()
For i = 1 To 15
Randomize
aa(i) = Int(99 * Rnd + 1)
For j = 1 To i - 1
If aa(i) = aa(j) Then
i = i - 1
End If
Next
Next
End Function
Private Sub Form_Load()
Call rand
Set Conn = New ADODB.Connection
Set Rs = New ADODB.Recordset
Conn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=tst"
Conn.Open
Rs.Open "select * from tk_yanyu", Conn, adOpenKeyset, adLockOptimistic
Rs.MoveFirst
End Sub