首页 > 中学考试杂题 > 题目详情
VB里的问题我这段查询是在一个文本框里显示的.我想改成表格形式的.Private Sub Command2 Click(
题目内容:
VB里的问题
我这段查询是在一个文本框里显示的.我想改成表格形式的.
Private Sub Command2_Click()
'查询
If Combo1.Text = "" Then
MsgBox "你没有选择查询方式,请选择!",16,"错误提示!"
Exit Sub
End If
If Combo1 "全部记录" And Text4.Text = "" Then
MsgBox "你没有填写查询的关键字,请填写!",16,"错误提示!"
Exit Sub
End If
Dim XX As Integer,SS As Integer
XX = 0:SS = 0:Text5.Text = "日 期" & Space(20) & "购买单位" & Space(16) & "用户单位" & Space(10) & "联系人" & Space(10) & "联系电话" & Space(10) & vbCrLf
Call SJK(db)
RS.Open "Select * From 表1",db,3,3
SS = RS.RecordCount
RS.Close
Set RS = Nothing
If Combo1.Text = "全部记录" Then
txtSQL = "Select * From 表1"
ElseIf Combo1.Text = "以姓名查询" Then
txtSQL = "Select * From 表1 Where T2 Like '%" & Text4.Text & "%'"
ElseIf Combo1.Text = "以内容查询" Then
txtSQL = "Select * From 表1 Where T3 Like '%" & Text4.Text & "%'"
End If
RS.Open txtSQL,db,2,2
Do While Not RS.EOF
XX = XX + 5
Text5.Text = Text5.Text & RS!T1 & 16 & RS!T2 & vbCrLf
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
If SS > 0 Then
If XX = 0 Then
MsgBox "对不起!你选择方式中的关键字可能有误,没有你查询的记录!请重新查询!",48,"无记录!"
End If
Else
MsgBox "对不起!你的数据库中没有记录,请首先录入记录!",48,"数据库是空的!"
End If
End Sub
Public Sub SJK(db)
db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\ABCD.mdb"
db.Open
End Sub
Private Sub Command3_Click()
Unload Me
其他查询.Show
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub MSFlexGrid1_Click()
End Sub
VB里的问题
我这段查询是在一个文本框里显示的.我想改成表格形式的.
Private Sub Command2_Click()
'查询
If Combo1.Text = "" Then
MsgBox "你没有选择查询方式,请选择!",16,"错误提示!"
Exit Sub
End If
If Combo1 "全部记录" And Text4.Text = "" Then
MsgBox "你没有填写查询的关键字,请填写!",16,"错误提示!"
Exit Sub
End If
Dim XX As Integer,SS As Integer
XX = 0:SS = 0:Text5.Text = "日 期" & Space(20) & "购买单位" & Space(16) & "用户单位" & Space(10) & "联系人" & Space(10) & "联系电话" & Space(10) & vbCrLf
Call SJK(db)
RS.Open "Select * From 表1",db,3,3
SS = RS.RecordCount
RS.Close
Set RS = Nothing
If Combo1.Text = "全部记录" Then
txtSQL = "Select * From 表1"
ElseIf Combo1.Text = "以姓名查询" Then
txtSQL = "Select * From 表1 Where T2 Like '%" & Text4.Text & "%'"
ElseIf Combo1.Text = "以内容查询" Then
txtSQL = "Select * From 表1 Where T3 Like '%" & Text4.Text & "%'"
End If
RS.Open txtSQL,db,2,2
Do While Not RS.EOF
XX = XX + 5
Text5.Text = Text5.Text & RS!T1 & 16 & RS!T2 & vbCrLf
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
If SS > 0 Then
If XX = 0 Then
MsgBox "对不起!你选择方式中的关键字可能有误,没有你查询的记录!请重新查询!",48,"无记录!"
End If
Else
MsgBox "对不起!你的数据库中没有记录,请首先录入记录!",48,"数据库是空的!"
End If
End Sub
Public Sub SJK(db)
db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\ABCD.mdb"
db.Open
End Sub
Private Sub Command3_Click()
Unload Me
其他查询.Show
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub MSFlexGrid1_Click()
End Sub
我这段查询是在一个文本框里显示的.我想改成表格形式的.
Private Sub Command2_Click()
'查询
If Combo1.Text = "" Then
MsgBox "你没有选择查询方式,请选择!",16,"错误提示!"
Exit Sub
End If
If Combo1 "全部记录" And Text4.Text = "" Then
MsgBox "你没有填写查询的关键字,请填写!",16,"错误提示!"
Exit Sub
End If
Dim XX As Integer,SS As Integer
XX = 0:SS = 0:Text5.Text = "日 期" & Space(20) & "购买单位" & Space(16) & "用户单位" & Space(10) & "联系人" & Space(10) & "联系电话" & Space(10) & vbCrLf
Call SJK(db)
RS.Open "Select * From 表1",db,3,3
SS = RS.RecordCount
RS.Close
Set RS = Nothing
If Combo1.Text = "全部记录" Then
txtSQL = "Select * From 表1"
ElseIf Combo1.Text = "以姓名查询" Then
txtSQL = "Select * From 表1 Where T2 Like '%" & Text4.Text & "%'"
ElseIf Combo1.Text = "以内容查询" Then
txtSQL = "Select * From 表1 Where T3 Like '%" & Text4.Text & "%'"
End If
RS.Open txtSQL,db,2,2
Do While Not RS.EOF
XX = XX + 5
Text5.Text = Text5.Text & RS!T1 & 16 & RS!T2 & vbCrLf
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
If SS > 0 Then
If XX = 0 Then
MsgBox "对不起!你选择方式中的关键字可能有误,没有你查询的记录!请重新查询!",48,"无记录!"
End If
Else
MsgBox "对不起!你的数据库中没有记录,请首先录入记录!",48,"数据库是空的!"
End If
End Sub
Public Sub SJK(db)
db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\ABCD.mdb"
db.Open
End Sub
Private Sub Command3_Click()
Unload Me
其他查询.Show
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub MSFlexGrid1_Click()
End Sub
本题链接: