Get a value after a piece of text

Moocow

Member
Joined
Jan 7, 2007
Messages
8
Programming Experience
Beginner
That's kind of a confusing thread title. What i need to do, is say, if TextBox1 contains "run C:/whatever.exe" when Button1 is pressed, how do i get the text after "run" and use it as a value, so it runs the directory entered after run? :confused:
 
VB.NET:
'Get the string from the textbox....
 
Dim MyStr as String = TextBox1.Text.Substring(4)
 
'Start the .exe
 
System.Diagnostics.Process.Start(Mystr)
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mystring [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]"run C:/whatever.exe"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] splitstring() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = mystring.Split([/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2])
MessageBox.Show(splitstring(1))
[/SIZE]
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mystring [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]"run C:/whatever.exe"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] splitstring() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = mystring.Split([/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MessageBox.Show(splitstring(1))[/SIZE]

until the exe name has a space in it.. :D
 
Back
Top