|
-
Aug 13th, 2001, 08:21 PM
#1
Thread Starter
Hyperactive Member
^_^ Retard----->
ok I ahve this code that gets last chat line wich is 'LastTextR' and code that gets last name LastSNR these are no probs but i dont understand this loop
Private Sub Command1_Click()
If LastTextR = Text1 Then
Loop Until LastTextR = Text1.Text
sendchatroom "Ty for helping me " + LastSNR
End If
End Sub
i'm trying to keep looping the LastTextR until it find a certain text like /test and when it sees /test it sends sendchatroom "hi"
the problem is when i hit the button it only checks the LastTextR one time...so i need to loop the LastTextR some how...i haven't got it figured out yet..anyone understand what i'm saying?
-
Aug 13th, 2001, 08:30 PM
#2
Addicted Member
maybe something like this...
Code:
Private Sub Command1_Click()
Dim SendIt as string
SendIt = SendToRoom
If LastTextR <> Text1.Text then
Loop Until LastTextR = Text1.Text
End If
If LastTextR = Text1.Text Then
SendIt
End Sub
Public Sub SendToRoom()
sendchatroom "Ty for helping me" & LastSNR
End Sub
This is untested code, so it may or may not work as you want it.
But maybe it helps.
-
Aug 13th, 2001, 11:18 PM
#3
Member
In your code:
VB Code:
Private Sub Command1_Click()
If LastTextR = Text1 Then
Loop Until LastTextR = Text1.Text
sendchatroom "Ty for helping me " + LastSNR
End If
End Sub
the line 'Loop Until...' has no 'Do' to go with it so it won't work.
When you say you want it to loop checking LastTextR, do you mean you want to keep checking LastTextR over time until you find a certain string (ie the value of LastTextR is changing), or do you mean you just want to search through LastTextR to see if another certain string is in it (such as "/test")? Or do you mean something else again?
If the value of LastNameR is changing, you will need to use a timer, or some other trigger to run your code again. If you just want to search for another string within LastNameR, try using the function 'InStr' - look it up in MSDN.
If I can understand what you want to do I'll be glad to help in more detail (with some example code), but at the moment i can't really understand what you're trying to do.
-
Aug 14th, 2001, 10:00 AM
#4
Addicted Member
The main problem he had with his code is this:
Code:
If LastTextR = Text1 Then
Loop Until LastTextR = Text1.Text
That snippet is basically saying that if Text1 is equal to LastTextR then loop until they are equal, in which they would already be. Correct me if I'm wrong but that seems to be the biggest mistake in this code.
-
Aug 15th, 2001, 11:07 AM
#5
Thread Starter
Hyperactive Member
Herbatic, you said
"When you say you want it to loop checking LastTextR, do you mean you want to keep checking LastTextR over time until you find a certain string (ie the value of LastTextR is changing), "
thats exactly what i'm trying to do...how can i keep looping LastTextR...till it finds "whatever"
-
Aug 15th, 2001, 11:19 AM
#6
Member
so, what you want is:
Once command1 has been pressed, every time LastTextR changes, you want to scan it to check if certain strings are in it.
if this is wht you want, you need to make a function (or sub) to scan LastTextR, and call it every time you change the value of LastTextR (or maybe make a function which is called to change the value of LastTextR, which also does this checking). If you want it to only scan for these strings if command1 has been pressed, you need to make a global variable (boolean maybe) which is set when you press command1, and is checked in the function to decide whether to inspect LastTextR.
I can't really be more specific unless you explain the bigger picture a little more. I hope this helps as is.
-
Aug 15th, 2001, 11:28 AM
#7
Thread Starter
Hyperactive Member
listen its a chatroom and this code i have reads the last chat line...but it only reads it 1 time...so i gotta loop it so it will keep checking the chat until it sees "/test"...understand?
-
Aug 15th, 2001, 11:32 AM
#8
Thread Starter
Hyperactive Member
I tried what Stephen Bazemore said but it still says loop without Do..how do i fix this? here is the variation i used of his code:
Code:
Private Sub Command1_Click()
If LastTextR <> Text1.Text then
Loop Until LastTextR = Text1.Text
End If
If LastTextR = Text1.Text Then
sendchatroom "TY for testing"
End Sub
where do i put the Do?
-
Aug 15th, 2001, 11:33 AM
#9
Thread Starter
Hyperactive Member
i tried this
Code:
Private Sub Command1_Click()
Do
If LastTextR <> Text1.Text Then
Do
Loop Until LastTextR = Text1.Text
End If
If LastTextR = Text1.Text Then
sendchatroom "TY"
End If
End Sub
and now its highlighting End Sub and saying Do without a loop..omg?
-
Aug 15th, 2001, 11:34 AM
#10
Thread Starter
Hyperactive Member
just noticed i had two Do's oops
-
Aug 15th, 2001, 11:40 AM
#11
Member
ok
so whenever a new line of chat message arrives, run a sub to check it for /test, maybe:
VB Code:
Public Sub ProcessChatMessage()
Dim lMsgPos As Long
lMsgPos = InStr(1, LastTextR, "/test")
If lMsgPos > 0 Then
' "/test" was found at lMsgPos
' do what you want here
End If
End Sub
I think your real problem though is finding where to run this sub. You just need to find where in your code the next message in the chat has arrived and check there, instead of it running all the time.
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
|