本文介绍了如何在vb 6.0中将listview的项目显示到消息框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想在vb 6.0的消息框中显示列表视图的项目
Hi i want to display the items of list view into a message box in vb 6.0
Private Sub Command1_Click()
CN.Open "Driver=sql server;server=SOFT2;DataBase=Timetronix;"
MsgBox "connect to the database"
REC.Open "Select * from CHECKINOUT where CHECKTIME BETWEEN '" & DTPicker1.Value & "' AND '" & DTPicker2.Value & "'", CN, adOpenStatic, adLockReadOnly
If REC.RecordCount > 0 Then
For i = 1 To REC.RecordCount
LstLog.ListItems.Add , , REC("SensorID")
LstLog.ListItems(i).SubItems(1) = REC("CheckTime")
LstLog.ListItems(i).SubItems(2) = IIf(IsNull(REC("EMPID")), "", REC("EMPID"))
REC.MoveNext
Next
REC.Close
CN.Close
End If
MsgBox "hello" & LstLog.listitems
End Sub
问题是数据来自数据库,但我无法在消息框中显示它们。
The problem is that data is coming from data base but i can't able to display them in message box..
推荐答案
Collapse | Copy Code
Private Sub Command1_Click()
CN.Open "Driver=sql server;server=SOFT2;DataBase=Timetronix;"
MsgBox "connect to the database"
REC.Open "Select * from CHECKINOUT where CHECKTIME BETWEEN '" & DTPicker1.Value & "' AND '" & DTPicker2.Value & "'", CN, adOpenStatic, adLockReadOnly
If REC.RecordCount > 0 Then
For i = 1 To REC.RecordCount
LstLog.ListItems.Add , , REC("SensorID")
LstLog.ListItems(i).SubItems(1) = REC("CheckTime")
LstLog.ListItems(i).SubItems(2) = IIf(IsNull(REC("EMPID")), "", REC("EMPID"))
MsgBox "hello " & LstLog.ListItems(i)
REC.MoveNext
Next
REC.Close
CN.Close
End If
'Or you can use LstLog.ListItems(i) & LstLog.ListItems(i).SubItems(1) & LstLog.ListItems(i).SubItems(2)
End Sub
如果您想获得有关vb6中消息框的信息,可以点击以下链接:
[]
[]
Best问候。
and if you want getting information about message box in vb6 you can follow of links:
http://visualbasic.freetutes.com/learn-vb6/lesson18.html[^]
http://www.vb6.us/tutorials/understanding-msgbox-command-visual-basic[^]
Best Regards.
Dim str As String
For Each itm in LstLog.ListItems
str=str & itm
Next
MsgBox("Hello " & str & " ")
Dim str As String
For Each col in LstLog.Columns
For Each itm in LstLog.ListItems
str=str & itm
Next
Next
MsgBox("Hello " & str & " ")
这篇关于如何在vb 6.0中将listview的项目显示到消息框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!