假如一个listbox中的每项是一个网址,请问VB高手,怎样遍历listbox中的每项,遍历到该项时,显示在textbox
5个回答
展开全部
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
List1.ListIndex = List1.ListIndex + 1
Text1 = List1.List(List1.ListIndex)
If List1.ListIndex = List1.ListCount - 1 Then Timer1.Enabled = False
End Sub
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
List1.ListIndex = List1.ListIndex + 1
Text1 = List1.List(List1.ListIndex)
If List1.ListIndex = List1.ListCount - 1 Then Timer1.Enabled = False
End Sub
展开全部
For i = 0 To List1.ListCount - 1
text1.Text = text1.Text & List1.List(i) & vbCrLf
Next
text1.Text = text1.Text & List1.List(i) & vbCrLf
Next
追问
追答
Dim a As Integer
Private Sub Command1_Click()
Text1.Text = List1.List(a)
a = a + 1
If a > List1.ListCount - 1 Then a = 0
End Sub
Private Sub Form_Load()
For i = 1 To 10
List1.AddItem i
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
For i = 0 To List1.ListCount - 1
if list1(i)="xxxxx" then
text1.text = list1(i)
endif
Next
if list1(i)="xxxxx" then
text1.text = list1(i)
endif
Next
追问
高手,,谢谢你的回答
不过问题还是没解决
我的意思是
点击command1按钮
textbox依次逐条显示
listbox中的内容,比如显示巴西后。。再显示阿根廷。。再显示。。。英格兰。以此类推,而不是将所有内容一下子放到textbox中,我想应该要用到timer控件吧,麻烦解答下,,,谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
textbox???不是VB6啊??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'动态添加控件测试,呵呵。
'窗体上不能有下列控件的名称。
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim WithEvents cX As CommandButton
Dim WithEvents cXS As CommandButton
Dim WithEvents cM As Timer
Dim cT As TextBox, WithEvents cL As ListBox
Private Sub Form_Load()
Caption = "通过Timer, 遍历listbox"
Width = 6000: Height = 3600
Set cX = Controls.Add("VB.CommandButton", "cX")
cX.Visible = True: cX.Width = 1600: cX.Left = Width - 1800
cX.Caption = "遍历listbo&x"
Set cXS = Controls.Add("VB.CommandButton", "cXS")
cXS.Visible = True: cXS.Width = 1600: cXS.Left = Width - 1800
cXS.Top = 600
cXS.Caption = "停止或开始"
Set cL = Controls.Add("vb.listbox", "cL")
cL.Visible = True: cL.Width = 4100: cL.Height = 2600
Set cT = Controls.Add("vb.textbox", "cT")
cT.Visible = True: cT.Width = 5800: cT.Top = 2700
cT.Height = 300: cT.Text = "动态控件测试..."
Set cM = Controls.Add("vb.timer", "cM")
cM.Enabled = True: cM.Interval = 1000
For i = 0 To 1000
cL.AddItem "http://zhidao.baidu.com/question/24018" & 4892 + i & ".html"
Next
End Sub
Private Sub cM_Timer()
Static iIndex%
iIndex = (iIndex + 1) Mod cL.ListCount
cT.Text = cL.List(iIndex)
End Sub
Private Sub cX_Click()
If cT.Text <> "" Then ShellExecute 0, "open", cT.Text, "", "", 1
Caption = cT.Text
End Sub
Private Sub cXS_Click()
cM.Enabled = Not cM.Enabled
End Sub
Private Sub cL_Click()
cM.Enabled = False
cT.Text = cL.List(cL.ListIndex)
End Sub
Private Sub cL_DblClick()
ShellExecute 0, "open", cL.List(cL.ListIndex), "", "", 1
End Sub
'窗体上不能有下列控件的名称。
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim WithEvents cX As CommandButton
Dim WithEvents cXS As CommandButton
Dim WithEvents cM As Timer
Dim cT As TextBox, WithEvents cL As ListBox
Private Sub Form_Load()
Caption = "通过Timer, 遍历listbox"
Width = 6000: Height = 3600
Set cX = Controls.Add("VB.CommandButton", "cX")
cX.Visible = True: cX.Width = 1600: cX.Left = Width - 1800
cX.Caption = "遍历listbo&x"
Set cXS = Controls.Add("VB.CommandButton", "cXS")
cXS.Visible = True: cXS.Width = 1600: cXS.Left = Width - 1800
cXS.Top = 600
cXS.Caption = "停止或开始"
Set cL = Controls.Add("vb.listbox", "cL")
cL.Visible = True: cL.Width = 4100: cL.Height = 2600
Set cT = Controls.Add("vb.textbox", "cT")
cT.Visible = True: cT.Width = 5800: cT.Top = 2700
cT.Height = 300: cT.Text = "动态控件测试..."
Set cM = Controls.Add("vb.timer", "cM")
cM.Enabled = True: cM.Interval = 1000
For i = 0 To 1000
cL.AddItem "http://zhidao.baidu.com/question/24018" & 4892 + i & ".html"
Next
End Sub
Private Sub cM_Timer()
Static iIndex%
iIndex = (iIndex + 1) Mod cL.ListCount
cT.Text = cL.List(iIndex)
End Sub
Private Sub cX_Click()
If cT.Text <> "" Then ShellExecute 0, "open", cT.Text, "", "", 1
Caption = cT.Text
End Sub
Private Sub cXS_Click()
cM.Enabled = Not cM.Enabled
End Sub
Private Sub cL_Click()
cM.Enabled = False
cT.Text = cL.List(cL.ListIndex)
End Sub
Private Sub cL_DblClick()
ShellExecute 0, "open", cL.List(cL.ListIndex), "", "", 1
End Sub
追问
高手,,谢谢你的回答
不过问题还是没解决
我的意思是
点击command1按钮
textbox依次逐条显示
listbox中的内容,比如显示巴西后。。再显示阿根廷。。再显示。。。英格兰。以此类推,而不是将所有内容一下子放到textbox中,我想应该要用到timer控件吧,麻烦解答下,,,谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询