求助:对象变量或with块变量未设置该怎么做?
Public Sub cboDataUser()Dim res As String
Dim txtsql As String
Dim rstcbo As ADODB.Recordset
Dim i As Integer
txtsql = "select UserId from tbUser"
res = ExecuteSQL(txtsql, rstcbo, False)
If rstcbo.RecordCount <> 0 Then For i = 0 To rstcbo.RecordCount - 1
cboLogin.AddItem (rstcbo.Fields(0))
rstcbo.MoveNext
Next
End If
End Sub
这是原代码 该怎么修改? --------------------编程问答-------------------- 红色代码是提示错误部分 拜托各位高手帮忙 --------------------编程问答-------------------- Dim rstcbo As ADODB.Recordset
Dim i As Integer
txtsql = "select UserId from tbUser"
res = ExecuteSQL(txtsql, rstcbo, False)
If rstcbo.RecordCount <> 0 Then
For i = 0 To rstcbo.RecordCount - 1
cboLogin.AddItem (rstcbo.Fields(0))
rstcbo.MoveNext
Next
End If
End Sub
--------------------编程问答-------------------- 使用这个:http://download.csdn.net/source/1498324 --------------------编程问答-------------------- If rstcbo.RecordCount <> 0 Then
For i = 0 To rstcbo.RecordCount - 1
--------------------编程问答-------------------- --------------------编程问答-------------------- If rstcbo.RecordCount > 0 Then
cboLogin.Clear
For i = 0 To rstcbo.RecordCount - 1
cboLogin.AddItem (rstcbo.Fields(0))
If Not rstcbo.Eof Then rstcbo.MoveNext
Next
End If
--------------------编程问答-------------------- If rstcbo.RecordCount > 0 Then
cboLogin.Clear
rstcbo.MoveFirst
For i = 0 To rstcbo.RecordCount - 1
cboLogin.AddItem (rstcbo.Fields(0))
If Not rstcbo.Eof Then rstcbo.MoveNext
Next
End If
补充:VB , 控件