一:
Private Sub Command1_Click()
MSFlexGrid1.Cols = 11
MSFlexGrid1.Rows = 10
c = 0
a = Textperson.Text
Data1.Recordset.FindFirst "姓名=" & "'" & a "'"
if Data1.Recordset.Nomatch Then
MsgBox "没有找到"
Else
'把查询结果放入MSFlexGrid1
Command3.Visible = True
End If
End Sub
二:
一种方法是:Dim Timer as String
Timer=Time$
别一种方法:用API,你查查API函数。
Private Sub Command1_Click()
MSFlexGrid1.Cols = 11
MSFlexGrid1.Rows = 10
c = 0
a = Textperson.Text
Data1.Recordset.FindFirst "姓名=" & "'" & a "'"
if Data1.Recordset.Nomatch Then
MsgBox "没有找到"
Else
'把查询结果放入MSFlexGrid1
Command3.Visible = True
End If
End Sub
二:
一种方法是:Dim Timer as String
Timer=Time$
别一种方法:用API,你查查API函数。
二:
一种方法:Dim Timer as String
Timer=Time$
Text1.Text=Timer
第二个问题的话,如果你获得系统时间是为了给用户看的话,就用statusbar控件来实现吧。直接在窗体上添加statusbar,然后把它的style属性设置为6就可以了。要显示在text框中的话就用timeserial函数。
Text1.Text = Time 时间
Text1.Text = Now 日起时间
和Time函数
Private Sub Command1_Click()
MSFlexGrid1.Cols = 11
MSFlexGrid1.Rows = 10
c = 0
a = Textperson.Text
Data1.Recordset.FindFirst "姓名=" & "'" & a & "'"
if Data1.Recordset.Nomatch Then
MsgBox "没有找到"
Else
'把查询结果放入MSFlexGrid1
Command3.Visible = True
End If
End Sub
二:
一种方法是:Dim Timer as String
Timer=Time$
Text1.text=Timer
别一种方法:用API,你查查API函数。
Do While Not Data1.Recordset.EOF
If c = 0 And Data1.Recordset("姓名") = a Then
End If
Data1.Recordset.MoveNext
Loop
的查询结果放到MSFlexGrid1里面啊?
up,up,up
form_a.show
text1.text=formb.MSFlexGrid1.TextMatrix(1,1)
End Sub
传入参数就可以的。
rows=1 '因为第一行为你的字段名
do while(mrc.eof=false)
rows=rows+1
with msglexgrid1
.rows=1 '因为第一行为你的字段名,第一列固定让他空着,这样比较美观
.rows=.row+1
for i=1 to mrc.fields.count
.textmatrix(.rows-1,i)=mrc.fields(i-1)
next i
mrc.movenext
loop如果你上面的数据集搞定的话,这个代码写进去因该没什么问题。有问题发消息给我!没问题记得给分哦!:)
dim intcount as integer
intCount=msglexgrid1.row
然后再把他写入到你所要的窗口中啊。
这里头要用到一条查询语句。其中的
select * from table_name where 字段名= '"& msglexgrid1.textmatrix(intCount,存在关键字的那一列的列号)&"'这下应该没问题了。
Best of Luck to you !
-----------------------------------------------------------------
Private Sub Command1_Click()
MSFlexGrid1.Cols = 11
MSFlexGrid1.Rows = 10
a = Textperson.Text
Data1.Recordset.MoveFirst
Data1.Recordset.find "姓名='" & a & "'"
if Data1.Recordset.Nomatch Then
MsgBox "没有找到"
End If
Command3.Visible = Not Data1.Recordset.Nomatch
End Sub
只要MSFlexGrid1与Data1绑定,如果找到,会自动定位到记录上。
---------------------------------------------------------
第二个问题:vb中怎样获得系统的时间。然后把系统时间显示在text框中?
txtSysTime = format(Now(), "yyyy-mm-dd hh:nn:ss")
不好意思!我上面所说的是没有用控件,我引用的是Microsoft ActiveX data object 2.6 Library 。但是思路应该是差不多的啊,你首先得记录当前的在MSFlexGrid中的位置的,如 第一条,第二条 ...
你要记住当前的记录号啊!
我想你的记录都在数据库中吧!
Dim intCount as integer
Dim txtSQL as string
dim Msgtext as string
dim mrc as adodb.recordset
dim i as integer
intCount=msglexgrid1.row
然后再把他写入到你所要的窗口中啊。
这里头要用到一条查询语句。其中的
select * from table_name where 字段名= '"& msglexgrid1.textmatrix(intCount,存在关键字的那一列的列号(如:姓名所在的那一列的列号))&"'
set mrc=ExecuteSQL(txtSQL,Msgtext) '我写的一个连接数据库的函数,在模块中,这里就不再述说了,我想你也能搞定。
'如果只有一列的话
text1.text=mrc.field(0)
'如果有多列的话
text1.text=mrc.field(0)
text2.text=mrc.field(1)
...这样就可以把你所要的记录都文本框中了!不会只出现投一条记录的!
Best of Luck to you !