主题:各位高手帮忙纠正一下 谢谢!!!
Dim adocon As New ADODB.Connection
Dim lurst As New ADODB.Recordset
Private Sub Form_Load()
adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\魏磊\db1.mdb;Mode=ReadWrite;Persist Security Info=False;"
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub okbutton_Click()
Dim str As String
Dim i, n As Integer
Dim a, b, c, d As Integer
c = a - b
d = a + b
a = Text1.Text
b = Text2.Text
MSFlexGrid1.Clear
Set cbrst = Nothing
cbrst.Open "select * from shuju where licheng between c and d"
If Not cbrst.EOF Then
MSFlexGrid1.Visible = True
MSFlexGrid1.Col = 1
MSFlexGrid1.Sort = flexSortStringAscending
MSFlexGrid1.Cols = 19
MSFlexGrid1.Rows = 5
MSFlexGrid1.TextMatrix(0, 0) = "序号"
i = 0
MSFlexGrid1.TextMatrix(i, 1) = "里程"
MSFlexGrid1.TextMatrix(i, 2) = "左高低"
MSFlexGrid1.TextMatrix(i, 3) = "右高低"
While Not cbrst.EOF
i = i + 1
MSFlexGrid1.TextMatrix(i, 0) = i
MSFlexGrid1.TextMatrix(i, 1) = cbrst.Fields(1).Value
MSFlexGrid1.TextMatrix(i, 2) = cbrst.Fields(2).Value
MSFlexGrid1.TextMatrix(i, 3) = cbrst.Fields(3).Value
cbrst.MoveNext
Wend
Else
n = MsgBox("没有找到符合条件的记录,是否重新查找?", vbYesNo + vbCritical, "查找结果")
If n = vbYes Then
MSFlexGrid1.Visible = False
End If
End If
End Sub
Dim lurst As New ADODB.Recordset
Private Sub Form_Load()
adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\魏磊\db1.mdb;Mode=ReadWrite;Persist Security Info=False;"
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub okbutton_Click()
Dim str As String
Dim i, n As Integer
Dim a, b, c, d As Integer
c = a - b
d = a + b
a = Text1.Text
b = Text2.Text
MSFlexGrid1.Clear
Set cbrst = Nothing
cbrst.Open "select * from shuju where licheng between c and d"
If Not cbrst.EOF Then
MSFlexGrid1.Visible = True
MSFlexGrid1.Col = 1
MSFlexGrid1.Sort = flexSortStringAscending
MSFlexGrid1.Cols = 19
MSFlexGrid1.Rows = 5
MSFlexGrid1.TextMatrix(0, 0) = "序号"
i = 0
MSFlexGrid1.TextMatrix(i, 1) = "里程"
MSFlexGrid1.TextMatrix(i, 2) = "左高低"
MSFlexGrid1.TextMatrix(i, 3) = "右高低"
While Not cbrst.EOF
i = i + 1
MSFlexGrid1.TextMatrix(i, 0) = i
MSFlexGrid1.TextMatrix(i, 1) = cbrst.Fields(1).Value
MSFlexGrid1.TextMatrix(i, 2) = cbrst.Fields(2).Value
MSFlexGrid1.TextMatrix(i, 3) = cbrst.Fields(3).Value
cbrst.MoveNext
Wend
Else
n = MsgBox("没有找到符合条件的记录,是否重新查找?", vbYesNo + vbCritical, "查找结果")
If n = vbYes Then
MSFlexGrid1.Visible = False
End If
End If
End Sub