数据多行显示
Private Sub cmdLogin_Click()
Dim rs_update As New ADODB.Recordset
Dim sql As String
Dim i As String
If Trim(txtcar.Text) = " " Then
MsgBox "车牌号不能为空! ", vbOKOnly + vbExclamation, " "
txtcar.SetFocus
Exit Sub
Else
sql = "select * from information "
rs_update.Open sql, conn, adOpenKeyset, adLockPessimistic
If Trim(rs_update.Fields(1)) = Trim(txtcar.Text) Then
MSFlexGrid1.Rows = 8
MSFlexGrid1.Cols = rs_update.RecordCount + 4
'-------------------------------
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "车辆编号 "
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "车牌号 "
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "车主手机号 "
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "车辆类别 "
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = "入场时间 "
If rs_update.EOF = False Then
rs_update.MoveFirst
Do While Not rs_update.EOF
MSFlexGrid1.Col = MSFlexGrid1.Row
MSFlexGrid1.Row = 1
MSFlexGrid1.Text = rs_update(0)
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = MSFlexGrid1.Row
MSFlexGrid1.Row = 1
MSFlexGrid1.Text = rs_update(1)
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = MSFlexGrid1.Row + 1
MSFlexGrid1.Row = 1
MSFlexGrid1.Text = rs_update(2)
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = MSFlexGrid1.Row + 2
MSFlexGrid1.Row = 1
MSFlexGrid1.Text = rs_update(3)
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = MSFlexGrid1.Row + 3
MSFlexGrid1.Row = 1
MSFlexGrid1.Text = rs_update(4)
MSFlexGrid1.Row = 1
rs_update.MoveNext
Loop
End If
Else
MsgBox "该车辆还没有进入,查无此车 ", vbOKOnly + vbExclamation, " "
txtcar.Text = " "
Exit Sub
End If
rs_update.Close
End If
End Sub
数据怎么在一行一条显示呀.而不是很多条数据在一行显示??
[解决办法]
我这只是一个例子,具体你自己要改呀
MSFlexGrid1.Col = 0 '第几列
MSFlexGrid1.Text = rs_update(0) '对应字段