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的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点
- The clock is a circle.是什么意思?
- 来自宇宙空间对地球造成威胁的有哪些天体?它们会对地球造成哪些影响?
- 甲乙两人共有1000元,甲取出了240元,乙又存了80元,这时甲的储蓄的钱数正好是乙的3倍,乙储蓄了多少元算
- 设三角形ABC的内角A,B,C的对应边分别是a,b,c,且cosA=3/5,cosB=5/13,b=3,求c?
- 胡萝卜,芹菜,苹果一起榨汁喝了真能减肥吗?
- would you like to have lunch with us应该怎样回答
- 保护鸟儿有哪些措施
- 仿写如下面的这条教师节短信,写一条给老师的短信
- 设二次方程ax^2+bx+c=0的两根为x1,x2,记S1=x1+2010x2,S2=x1+2010x2^2,……,
- 100分闯关六年级