不连接数据库,用数组给DataGrid赋值为什么不显示数据
不连接数据库,用数组给DataGrid赋值为什么不显示数据,哪里有问题Private Sub Command1_Click()
Dim i As Integer
Dim aa() As String
Dim adoRecordset As ADODB.Recordset
Set adoRecordset = New ADODB.Recordset
x = 2: y = 8
ReDim aa(x - 1, y - 1) As String
For i = 0 To x - 1
For j = 0 To y - 1
aa(i, j) = i * 10 * j '数组赋值
Next j
Next i
For i = 0 To x - 1 '为Recordset2个字段,即为 DataGrid 添加2列
adoRecordset.Fields.Append "第" & i & "列", adVariant, , adFldMayBeNull + adFldIsNullable + adFldUpdatable
Next i
adoRecordset.Open
For i = 0 To y - 1
adoRecordset.AddNew ' 加8条记录,即为 DataGrid 添加8空行
Next i
adoRecordset.MoveFirst
For j = 0 To y - 1
For i = 0 To adoRecordset.Fields.Count - 1
adoRecordset.Fields(i).Value = aa(i, j) '数据输入记录集
Next i
adoRecordset.MoveNext
Next j
Set DataGrid1.DataSource = adoRecordset
End Sub
[[italic] 本帖最后由 烟雨袅袅 于 2007-12-9 15:02 编辑 [/italic]]
信息文件.rar
(2.75 KB)