实时错误信息‘9’下标越界
语句是:Private Sub Command1_Click()Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim connect As String
connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=jchisn;Data Source=JXJXYY"
Set Conn = New ADODB.Connection
Conn.Open connect
Dim SQL As String
If Text1.Text <> "" Then
DataGrid1.Caption = "已发药品查询信息"
SQL = "select offname '科室',patname '姓名',medname '药品名称',medspec '规格',roomunit '单位',number '数量',roomprice '单价',selfallmoney '金额',exectime '发药时间' from dbo.AdviceListView where offcode = '" & Trim(Text1.Text) & "'"
Set rs = New ADODB.Recordset
rs.Open SQL, Conn, adOpenStatic
Set DataGrid1.DataSource = rs
'设置列宽
With DataGrid1
.Columns(0).Width = 600
.Columns(1).Width = 750
.Columns(2).Width = 1500
.Columns(3).Width = 1200
.Columns(4).Width = 400
.Columns(5).Width = 500
.Columns(6).Width = 800
.Columns(7).Width = 1500
.Columns(8).Width = 800
.Columns(9).Width = 800
.Columns(10).Width = 2800
End With
End If
End Sub
却出现错误信息:实时错误信息‘9’下标越界,
调式显示为 .Columns(9).Width = 800
请各位帮我看一下