本文介绍了在listivew中出错(未设置带块或不带块的对象变量)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Private Sub Form_Load()
Dim iInt As Integer
Dim SQL As String
Dim r as recordset
ListView1.ListItems.clear
SQL = "Select * from DISTRICT order by district_code asc"
r.Open SQL, c
While r.EOF = False
Set l = ListView1.ListItems.Add(, , r(0) & "")
l.SubItems(1) = Trim(r(1) & "")
r.MoveNext
Wend
ListView1.Visible = True
r.Close
End sub
在listivew中出错(未设置带块或不带块的对象变量).
Getting error in listivew (object variable with block or without block not set).
推荐答案
r.Open SQL, c
因为r
被声明为记录集对象,但从未设置.
您需要添加引用ADO,然后声明:
becouse r
is declared as recordset object but never set.
You need to add reference ADO and then declare:
Dim r as ADODB.Recordset
Set r = New ADODB.Recordset
有关更多帮助,请访问:
http://support.microsoft.com/kb/168336 [ ^ ]
http://support.microsoft.com/kb/315974 [ ^ ]
http://www.timesheetsmts.com/adotutorial.htm [ ^ ]
More help at:
http://support.microsoft.com/kb/168336[^]
http://support.microsoft.com/kb/315974[^]
http://www.timesheetsmts.com/adotutorial.htm[^]
这篇关于在listivew中出错(未设置带块或不带块的对象变量)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!