题目
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
提问时间:2021-12-02
答案
'添加一个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
'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的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1矛盾发展的不平衡性主要表现在哪些方面
- 2Mrs Green is a mother of two children.of不是用在无生命的吗
- 3若3cos(∏/2-θ)+cos(∏+θ)=0,则cos²θ+1/2sin2θ=?
- 4bob is not promised to join in the football match____ he has to help his parents on the farm
- 5昭君出塞发生在西汉哪位皇帝在位期间?昭君出塞这件事有何重大历史意义
- 6根据算式24X3X5编一道应用题
- 7六年级上册数学黄冈金榜课课练第36页第七题请帮助
- 8某厂试制一种新产品,成本费共700元.如果每个售价2元,试问至少要售价出多少个才能获得不低于1000元的盈利
- 9用橡皮筋捆铅笔,要求用4根橡皮筋捆九支铅笔,每捆铅笔必须都是单数,请问你有什么好办法?
- 10实数a大于0,函数f(x)=x平方log小4 a (1)如果方程f(x减1)加2x=0无实数跟,求a的取值范围 快
热门考点
- 1Now I miss you.And now I need
- 2太阳历是不是用象形文字写的
- 3英语能人进.
- 4“粉身碎骨浑不怕,要留清白在人间.”这两句借石灰吟之口,一语双关,表达出作者怎样的人生追求?
- 5have you seen the girl __composition we dicussed yesterday
- 6什么字是指他是牧羊人
- 7对实数X和Y,定义运算符号“*”为X*Y=X^2+Y^2+X+Y,求方程(X+2)*X=26的正整数解
- 8如图,以O为圆心的两个同心圆中,大圆的弦AB切小圆于点C,若AB=8,圆环的面积是 _ .
- 9一道电学的计算题目.
- 10He always take full __________ of the mistakes made by his rivals.(对手)