VB的问题 新手做数据库的课程设计遇到的 无效使用Null 各位给看看~
Private Sub Form_Load()
MSComm1.CommPort = 2 '设置串口为COM2
MSComm1.Settings = "9600,n,8,1" '传输率为9600bit/s,无奇偶校验位,8位数据,1位停止
MSComm1.RThreshold = 1 '接收缓冲区每收到1个字节字符,都会触发执行MSComm控件的OnComm()事件函数
MSComm1.SThreshold = 0 '数据发送事件不产生OnComm()事件
MSComm1.InputLen = 1 '使用Input()函数时读取接收缓冲区的字符个数,0表示全部读取
MSComm1.PortOpen = True '打开串口
MSComm1.Output = "6" '向单片机发送字符6表示启动了VB,要求单片机发送当前设置的报警上限值
Dim DBConn As New ADODB.Connection
Dim my As String
DBConn.CursorLocation = adUseClient
DBConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\数据库.mdb;"
Dim queryStr As String
queryStr = "select * from measuringrecord order by serial desc"
Dim rs As New ADODB.Recordset
Set rs = DBConn.Execute(queryStr)
MSFlexGrid1.Cols = rs.Fields.Count '设置列数
MSFlexGrid1.Rows = 1 '设置行数,目前可以确定的是只有一行
MSFlexGrid1.ColWidth(0) = 1600 '设置第1列的宽度
For i = 1 To rs.Fields.Count - 1 '设置剩余的列的宽度(等距离)
MSFlexGrid1.ColWidth(i) = (MSFlexGrid1.Width - MSFlexGrid1.ColWidth(0)) / (rs.Fields.Count - 1)
Next i
For i = 0 To rs.Fields.Count - 1 '设置第1行的值
MSFlexGrid1.ColAlignment(i) = 3 '各列文字居中显示
MSFlexGrid1.TextMatrix(0, i) = rs.Fields(i).Name '第一行中各列的值为数据库中测量记录表的列名
Next i
Do While Not rs.EOF '读取记录,直到指针指向末尾
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1 '增加一行用来存储读取的记录
For i = 0 To rs.Fields.Count - 1 '将读取的记录的值在增加的行中显示
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, i) = rs.Fields(i).Value 这里是调试窗口标黄的语句 求解答
Next i
rs.MoveNext '指针移向下一条记录
Loop
End Sub