VB里的问题

VB里的问题

题目
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
答案
'添加一个MSFlexGrid1把
'Do While Not RS.EOF
'XX = XX + 5
'Text5.Text = Text5.Text & RS!T1 & 16 & RS!T2 & vbCrLf
'RS.MoveNext
'Loop
'RS.Close
'这段改为:
With MSFlexGrid1
.FixedCols = 0
.FixedRows = 1
.Cols = 5
.FormatString = "日 期|购买单位|用户单位|联系人|联系电话"
.ColWidth(0) = 2000 '列宽(数值自己修改)
.ColWidth(1) = 2000
.ColWidth(2) = 2000
.ColWidth(3) = 2000
.ColWidth(4) = 2000
Dim i As Integer
Do While Not RS.EOF
XX = XX + 5
i = i + 1
If i >= .Rows Then .Rows = i + 1
.TextMatrix(i, 1) = RS!T1 '不知道你的T1 T2是第几列的值自己修改吧
.TextMatrix(i, 2) = RS!T2
RS.MoveNext
Loop
RS.Close
End With
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
热门考点

超级试练试题库

© 2017-2019 超级试练试题库,All Rights Reserved.