how to find the first two char of a string ?

ayufans
ayufans used Ask the Experts™
on
Hi..

How do you find the first two char of a string ? for example :

the string is "Whaddaheck".

How do I get only "Wh" and "ck" in the back ? in SQL we can simply use left and right syntax, but what about in VB 6.0 ?? should it be inst, substr or something ? I'm really lost here.. I know it's possible, since I've done it once, but what is the syntax to use ??? please lemme know...

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Developer
Commented:
try
MsgBox Left("Whaddaheck", 2)
MsgBox right("Whaddaheck", 2)

Author

Commented:
no.. I need the value to be stored in a variable instead of output it into a message box. I need to do other query to access db.
Just send it to a variable instead of a messagebox:

dim strLeftTwo as string
dim strRightTwo as string

strLeftTwo = Left("Whaddaheck", 2)
strRightTwo = Right("Whaddaheck", 2)

*** Please award the points to mnasman as he deserves the credit for this ***
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
Also if you are dealing with a sting and you know it dont use left and right ... use left$ and right$ - they are about 25 % faster ;)

Author

Commented:
thanks both, I'm awarding the point to mnasman according to the instruction ^_^ thanks.
ayufans, I see that you give many low grades on questions - this could cause experts to ignore your questions.

Why did you give the B? Was there a problem with the answer? Did you expect more? If not, please award Mohammed (mnasman) a grade of A.
You can do this by posting a 0-point question in the Community Support topic:
http://www.experts-exchange.com/Community_Support/
please include the URL to this question

You can get information on grading questions and other information in the help section. See this for example
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/cmtyQuestAnswer.jsp#3

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial