• Welcome to Valhalla Legends Archive.
 

[VB] what is it....

Started by WiLD, April 07, 2003, 01:39 AM

Previous topic - Next topic

WiLD

ok im going good on C++ now but i need help on VB  :-\
ok i got a script, i used the search feature to find it but where would i paste it.
would i paste it in the main form source?

heres the script:
if Instr(textline, " ") > 1 Then
 cmd = Split(textline, " ")(0)
 arg1 = Split(textline, " ")(1)
end if


or would i add it in a module?
=_=  &&  g0dFraY  &&  -=Templar=-  @USWest

Banana fanna fo fanna

What the fuck? Explain please.

PaiD

What r you trying to do?

Grok

if Instr(textline, " ") > 1 Then
 cmd = Split(textline, " ")(0)
 arg1 = Split(textline, " ")(1)
end if


Hey I recognize that snippet.  I pasted that as a response to a previous question about how to parse a trigger and its operands.  You should use it in the section of code where you interpret a complete line of channel speech.

Pretending your trigger marker is "/", you might have something like...


   Select Case True
   Case Left(textline, 1) = "/"     'found a trigger .. parse and see which one.
       if Instr(textline, " ") > 1 Then
           cmd = Split(textline, " ")(0)
           arg1 = Split(textline, " ")(1)
           Select Case True
           Case strComp(cmd,"ban")=0            'user wants someone banned
               'handle ban request here..
           Case strComp(cmd,"kick")=0            'user wants someone kicked
               'handle kick request here
           Case strComp(cmd,"say")=0            'you get the point
           Case strComp(cmd,"des")=0
           Case strComp(cmd,"reconnect")=0
           End Select
       end if
   Case Else
       'isn't a trigger request .. evaluate it in other ways...
   End Select


Got it?

Camel

heh, i've not seen anybody use a vb "select case true" in a long time...seems to be more of a perl/php thing

Grok

There are two ways in which select case true/false is useful.  When you want to pretty-up a big if-elseif-else-endif is one.  The other is to perform an AND or an OR conditional on multiple inputs.

c0ol

perl would use an if elsif else statement.  and why split the string 2 times? cant you ( i know 0% VB ) do like (cmd, args) = split(text,' ', 1) where args is a string array and cmd is a string.

Mesiah / haiseM

]HighBrow Innovations
Coming soon...

AIM Online Status: 

Camel

Quote from: c0ol on April 10, 2003, 12:07 AM
perl would use an if elsif else statement.  and why split the string 2 times? cant you ( i know 0% VB ) do like (cmd, args) = split(text,' ', 1) where args is a string array and cmd is a string.
that's the one thing i miss about perl
you can't grab them both in one line of code, but you don't need to call split twice:
Dim splitCmd() as String
splitCmd = Split(textline, " ", 2)
cmd = splitCmd(0)
arg = splitCmd(1)