Results 1 to 11 of 11

Thread: ^_^ Retard----->

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297

    ^_^ 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?

  2. #2
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    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.
    Stephen Bazemore
    Email:[email protected]

  3. #3
    Member
    Join Date
    Aug 2001
    Posts
    51
    In your code:
    VB Code:
    1. Private Sub Command1_Click()
    2. If LastTextR = Text1 Then
    3.     Loop Until LastTextR = Text1.Text
    4.     sendchatroom "Ty for helping me " + LastSNR
    5. End If
    6. 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.

  4. #4
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    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.
    Stephen Bazemore
    Email:[email protected]

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    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"

  6. #6
    Member
    Join Date
    Aug 2001
    Posts
    51
    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.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    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?

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    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?

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    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?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    just noticed i had two Do's oops

  11. #11
    Member
    Join Date
    Aug 2001
    Posts
    51
    ok
    so whenever a new line of chat message arrives, run a sub to check it for /test, maybe:

    VB Code:
    1. Public Sub ProcessChatMessage()
    2. Dim lMsgPos As Long
    3. lMsgPos = InStr(1, LastTextR, "/test")
    4. If lMsgPos > 0 Then
    5.     ' "/test" was found at lMsgPos
    6.     ' do what you want here
    7. End If
    8. 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
  •  



Click Here to Expand Forum to Full Width