Having trouble grabbing certain text from string

12padams

Well-known member
Joined
Feb 19, 2010
Messages
48
Programming Experience
Beginner
------------------------------Main Problem------------------------------

So I am making a game and within the game is a pretend terminal and lots of programs.

A certain goal I wish to achieve to allow the user to type the coordinates of a window and have that window move to the coordinates. I need to take those coordinates from the users command.

Lets say the program they want to move is called "knowledge input" the user would then typing in the terminal:

"move knowledge input to 50,380"

This text is then turned into a string called command. So far I know how to grab the 380 and set the y coordinate of the program from that but I can't grab the 50 and set the x coordinate.

Here is my code:

VB.NET:
If command Like "move knowledge input to *" Then
            command = command.Replace(", ", ",")   'removes space after comma in-case user types a space after the comma
            Knowledge_Input.Location = New Point(50, command.Substring(command.LastIndexOf(",") + 1, command.Length - (command.LastIndexOf(",") + 1)))
End If

As you can see I have simply put 50 there because for the life of me I can't work out what to type to grab that "50" or whatever the user typed for the x coordinate.

I know this one isn't that hard but trying to work this out has given me a headache!

------------------------------End Main Problem------------------------------

Thanks in advance for any help ;)


------------------------------Other Extended Question------------------------------
On another note... I am copying and pasting this If statement for each form and reusing the code like follows:

If command Like "move knowledge input to *" Then
If command Like "move shiftorium to *" Then
If command Like "move clock to *" Then

Is this the way you would do it or is there an easy efficient way to have it work automatically for each program in the game?

------------------------------End Other Extended Question------------------------------
 
Back
Top