|
-
Feb 9th, 2012, 10:31 AM
#1
Thread Starter
New Member
[RESOLVED] [HELP] Detect String
EDIT: Thanks to LaVolpe and jpbro, the code is:
Code:
Dim iPos As Integer
iPos = InStr(1, LogText, "!ban", vbTextCompare)
If iPos Then
banTxt = Mid$(LogText, iPos + 4) ' +4 is length of !ban
'Command
Else
End If
Hey Guys!
I had a thread in MSDN Help Center, and they redirected me to this forum as I have VB6. I have the Enterprise version (legal of course), and I need help.
Code:
If (InStr(1, LogText, "!ban ", vbTextCompare) > 0) Then
Call SendMessage(hWndTextbox, WM_SETTEXT, 0, "/ban ")
Call PostMessage(hWndTextbox, WM_KEYDOWN, VK_RETURN, 0)
Sleep (75)
End If
This is what I am trying to do^. I want to detect text from my chat box in my game. If it detects "!ban XXXXXX" from a user, I want to send a "/ban XXXXXX" from a server hoster (me). How do I detect the input after "!ban "?
Call SendMessage(hWndTextbox, WM_SETTEXT, 0, "/ban " & "//HERE\\")
^
Thanks In Advanced.
Last edited by Vlad1k; Feb 9th, 2012 at 03:06 PM.
Reason: [RESOLVED]
-
Feb 9th, 2012, 12:32 PM
#2
Re: [HELP] Detect String
Welcome to the forums.
InStr returns the position where !ban was found. To return the characters after that position, use Mid$()
Code:
Dim iPos As Integer
iPos = InStr(1, LogText, "!ban", vbTextCompare)
If iPos Then
banTxt = Mid$(LogText, iPos + 4) ' +4 is length of !ban
... send the text
Else
End If
But since LogText, I would assume can contain several lines of text, you may also need to test for the end of the line which !ban was found in?
-
Feb 9th, 2012, 12:34 PM
#3
Last edited by jpbro; Feb 9th, 2012 at 12:34 PM.
Reason: Late to the party
-
Feb 9th, 2012, 03:02 PM
#4
Thread Starter
New Member
Re: [HELP] Detect String
Thank you LaVolpe, you are a life saver! +REP.
Thank you jpbro for trying. +REP.
The code ran perfectly, now I can make major commands for my Server Mod.
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
|