|
-
May 18th, 2010, 11:29 PM
#1
Thread Starter
Member
loop list help
Code:
Dim i As Integer
For i = 0 To List2.ListCount - 1
msgbox(list2.list(i), "word")
Next i
list2.clear
timer2.enabled = false
it goes through the list timer2's interval. popups whatever the item is on. at the end of the list clears, and turns off the time. but its not working
-
May 18th, 2010, 11:49 PM
#2
Re: loop list help
What's not working? What's the problem?
-
May 19th, 2010, 12:31 AM
#3
Re: loop list help
If you want the selected item, the correct property is ListIndex.
Code:
Msgbox List2.list(list2.listindex)
-
May 19th, 2010, 01:10 AM
#4
Junior Member
Re: loop list help
Code:
Private Sub Form_Initialize()
For i = 0 To 10
List1.AddItem i
Next i
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
For i = 0 To List1.ListCount - 1
MsgBox List1.List(i), 64, "word"
Next i
List1.Clear
Timer1.Enabled = False
End Sub
-
May 19th, 2010, 01:10 AM
#5
Junior Member
Re: loop list help
MsgBox List1.List(i), 64, "word"
中间为64,参数不对,能运行么
-
May 19th, 2010, 02:27 AM
#6
Thread Starter
Member
Re: loop list help
hm no error on the loop list
but does this look wrong at all
Code:
Private Sub Check3_Click()
If Check3.Value = True Then
Timer1.Enabled = True
ElseIf Check3.Value = False Then
Timer1.Enabled = False
End If
End Sub
-
May 19th, 2010, 02:42 AM
#7
Junior Member
Re: loop list help
Code:
Private Sub Check3_Click()
If Check3.Value = 1 Then
Timer1.Enabled = True
Call Addstr
ElseIf Check3.Value = 0 Then
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Initialize()
Check3.Value = 1
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
If Check3.Value = 1 Then
For i = 0 To List1.ListCount - 1
MsgBox List1.List(i), 64, "word"
Next i
List1.Clear
End If
Timer1.Enabled = False
End Sub
Sub Addstr()
For i = 0 To 10
List1.AddItem i
Next i
End Sub
-
May 19th, 2010, 05:57 AM
#8
Re: loop list help
 Originally Posted by Hoppus
hm no error on the loop list
but does this look wrong at all
Code:
Private Sub Check3_Click()
If Check3.Value = True Then
Timer1.Enabled = True
ElseIf Check3.Value = False Then
Timer1.Enabled = False
End If
End Sub
Does it work?
-
May 19th, 2010, 07:03 AM
#9
Re: loop list help
You need to dim "i" outside of the timer event, then send one item each time the timer fires, then increment "i" after the "send" happens.
For example:
Code:
Option Explicit
Dim i As Integer
Private Sub Timer1_Timer()
sock.SendIM List2.List(i), "yep", False
i = i + 1
'also, check at this point to see if i is > than list2.listcount-1
End Sub
-
May 19th, 2010, 07:27 AM
#10
Re: loop list help
Why not simply:
vb Code:
Timer1.Enabled = Check3.Value
-
May 19th, 2010, 07:43 AM
#11
Thread Starter
Member
Re: loop list help
well i dimmed i in form load.
and
Code:
Private Sub Timer2_Timer()
For i = 0 To List2.ListCount - 1
sock.SendIM List2.List(i), "yep", False
i = i + 1
Next i
'also, check at this point to see if i is > than list2.listcount-1
End Sub
and now it's only sock.sendim-ing to the first item on the list. :\
-
May 19th, 2010, 08:07 AM
#12
Re: loop list help
Take the For loop out of your timer event (refer back to my earlier post), and that should do it for you.
-
May 19th, 2010, 08:23 AM
#13
Thread Starter
Member
Re: loop list help
well when i take out that out, it errors on next i. and when i take that out. it only does sock.sendim for the first item in the list
-
May 19th, 2010, 08:59 AM
#14
-
May 19th, 2010, 09:29 AM
#15
Re: loop list help
Can you post what code you now have?
What you describe shouldn't be happening if 1) you dim i outside the timer event and 2) you take the For...Next out and increment i manually inside the timer event.
-
May 19th, 2010, 10:20 AM
#16
-
May 20th, 2010, 07:07 AM
#17
Thread Starter
Member
Re: loop list help
 Originally Posted by vbfbryce
Can you post what code you now have?
What you describe shouldn't be happening if 1) you dim i outside the timer event and 2) you take the For...Next out and increment i manually inside the timer event.
Code:
Private Sub Timer2_Timer()
sock.SendIM List2.List(i), "yep", False
i = i + 1
List2.Clear
Timer2.Enabled = False
End Sub
Code:
Private Sub Form_Load()
Dim i As Integer
End Sub
I don't know if there's any specific way i should be adding items to the list. but this is what i have.
Code:
Dim lngIndex As Long
Dim bFound As Boolean
For lngIndex = 0 To List2.ListCount - 1
If strUserName = List2.List(lngIndex) Then
bFound = True
Exit For
End If
Next
If Not bFound Then
List2.AddItem strUserName
End If
but yeah. when looping list, it only sock.sendim's to the first item in the list. 
help resolve?
-
May 20th, 2010, 07:25 AM
#18
Re: loop list help
See if this works for you
Code:
Private Sub Timer2_Timer()
Static j As Integer
sock.SendIM List2.List(j), "yep", False
j = j + 1
If j = List2.ListCount Then
List2.Clear
Timer2.Enabled = False
j = 0
End If
End Sub
-
May 20th, 2010, 08:17 AM
#19
Thread Starter
Member
Re: loop list help
thanks markt. worked like a charm
-
May 20th, 2010, 09:31 AM
#20
Hyperactive Member
Re: loop list help
The ''Dim i As Integer'' could not be seen in the Timer2 sub.
It needed to look like this
Code:
Option Explicit
Dim i As Integer 'This is Public to the Form
Private Sub Check3_Click()
Timer1.Enabled = Check3.Value
End Sub
Private Sub Form_Load()
Dim i As Integer 'This is Private to the Form_Load
i= 777
Me.Caption = i
End Sub
Private Sub Timer1_Timer()
i = i + 1
If i > 3000 Then i = 0
Me.Caption = i
End Sub
Note: Static j As Integer is best
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|