新手求指点,一个老问题“实时错误9 下标越界”
'网格控件加载函数
Private Sub adoBInfoRefresh()
'设置ADO控件adoBInfoRefresh的连接字符串
adoBInfo.ConnectionString = CONSTR
'设置数据源
Dim tmpRecordSource As String
tmpRecordSource = "SELECT i.BookNo AS 图书编号, i.BookName AS 图书名称," _
+ " t.TypeName AS 图书类型名称, i.Author AS 作者, i.Publisher AS 出版社," _
+ " i.Price AS 图书价格, i.Memo AS 图书说明" _
+ " FROM BookInfo i, BookType t" _
+ " WHERE i.TypeID = t.TypeID" _
+ condition + " ORDER BY i.BookNo"
adoBInfo.RecordSource = tmpRecordSource
adoBInfo.Refresh
'设置列宽
With dtgBInfo
.Columns(0).Width = 1000
.Columns(1).Width = 1500
.Columns(2).Width = 1500
.Columns(3).Width = 1200
.Columns(4).Width = 1500
.Columns(5).Width = 1000
.Columns(6).Width = 2000
End With
End Sub
新学VB,从同学那里借来的一套图书管理的系统,运行总是提示“下标越界”,恳请高手解惑!!
[解决办法]
我上面回的有问题
adoBInfo.Refresh
set dtgBInfo.DataSource = adoBInfo
'设置列宽
With dtgBInfo
.Columns(0).Width = 1000
.Columns(1).Width = 1500
.Columns(2).Width = 1500
.Columns(3).Width = 1200
.Columns(4).Width = 1500
.Columns(5).Width = 1000
.Columns(6).Width = 2000
End With
End Sub