Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine the first three letters in a textbox? 1

Status
Not open for further replies.

JimHutton

Programmer
Sep 26, 2003
25
0
0
GB
Hi there.

How do I determine what three letters are at the beginning of a textbox, I would like to have a single textbox, which does a series of commands,

If DIR ........
then the program needs to open the directory specified
e.g

DIR C:\Program Files

Opens program files and so on,

Any ideas how i can do this too?


Kindest Regards
Jim
-
 

First to find the first 3 letter you can use...
[tt]
MyCommand = Left(Text1.Text, 3)
[/tt]
Then if you want to test for various commands...
[tt]
Select Case UCase(MyCommand)
Case "DIR"
'Do Something
Case "WVR"
'Do What eVeR
End Select
[/tt]
However you are limiting the number of commands that you can use by only the first 3 letters. You may want to test for a space instead...
[tt]
MyCommand = Left(Text1.Text, Instr(1, Text1.Text, " ") -1)

Select Case UCase(MyCommand)
Case "DIR"
Case "MKDIR"
Case "CHDIR"
End Select
[/tt]

Good Luck

 
You can try:

dim str as String;
str = Left(myTextBox.Text(), 3);


and then you can just use a select statement to act based on the value of str:

Select Case str
Case 1
if str = "dir" then
' do some work
Case Else
' do something else, etc
 
thank you.
Works like a treat.

Kindest Regards
Jim
-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top