Waverlyt
02-18-2001, 07:57 PM
i've been trying to make an interface similar to what you see in MUDs. you type something in and the game slices up your entry into stuff it can use, like:
get all bag
it would see 'get' and 'all' and 'bag' in that order. so far, i have this:
Dim Parsed As Variant
Private Sub ParseCommand()
Dim ParseText As String
ParseText = Text1.Text
Parsed = Split(ParseText, , 4)
End Sub
Private Sub Form_Load()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
ParseCommand
Select Case LCase(Parsed(0))
Case "buy"
If Parsed(1) = "" Or Parsed(1) = Null Then
MsgBox "Buy what?", , ""
Exit Sub
Else
MsgBox "You bought something!", , ""
End If
Case "sell"
If Parsed(1) = "" Or Parsed(1) = Null Then
MsgBox "Sell what?", , ""
Exit Sub
Else
MsgBox "You sold something!", , ""
End If
End Select
Else
End If
End Sub
it takes each part of the command (parts are separated by spaces) and puts it into an elemnt of an array. the only problem is, i *need* that array to always have 4 elements, even if they have nothing in them. The Split() function won't do this, it only has a parameter for the MAX number of elements in an array. Any help would be appreciated =)
Wav
get all bag
it would see 'get' and 'all' and 'bag' in that order. so far, i have this:
Dim Parsed As Variant
Private Sub ParseCommand()
Dim ParseText As String
ParseText = Text1.Text
Parsed = Split(ParseText, , 4)
End Sub
Private Sub Form_Load()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
ParseCommand
Select Case LCase(Parsed(0))
Case "buy"
If Parsed(1) = "" Or Parsed(1) = Null Then
MsgBox "Buy what?", , ""
Exit Sub
Else
MsgBox "You bought something!", , ""
End If
Case "sell"
If Parsed(1) = "" Or Parsed(1) = Null Then
MsgBox "Sell what?", , ""
Exit Sub
Else
MsgBox "You sold something!", , ""
End If
End Select
Else
End If
End Sub
it takes each part of the command (parts are separated by spaces) and puts it into an elemnt of an array. the only problem is, i *need* that array to always have 4 elements, even if they have nothing in them. The Split() function won't do this, it only has a parameter for the MAX number of elements in an array. Any help would be appreciated =)
Wav