• Status: Solved
• Priority: Medium
• Security: Public
• Views: 205

# Split a string that can return to sub strings of it?

Hi
I want to take a string in as:- (8 characters long)

Orgstr.text = var

I then want to Split this string(var) in two, with each sub string containing 4 characters.

Also does anyone know how to refernce a character in ascic?

Thanks
Glenelly22
0
glenelly22
• 3
• 3
• 2
• +2
1 Solution

Commented:
Hi glenelly22,

Orgstr.Text = var
Orgstr1.Text = Left(var,4)
Orgstr2.Text = Right(var,4)

To reference a character as an ascii code:

Chr(n) where n is the appropriate ascii code. To do it the other way round: Asc("A") will return ascii code 65.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk

Brainbench MVP for Visual Basic
http://www.brainbench.com

0

Commented:
a = "abcdefgh"
b = Mid(a, 1, 4)
c = Mid(a, 5, 4)
Print b, c
0

Commented:
Will it allways be exactly 8 chars long?

if you have a variable length string then try this
a = "whate"
b = Mid(a, 1, len(a)\2)
c = Mid(a, (len(a)\2)+1)
0

IT OperationsCommented:
Note to all:
Not use Mid, left or right function with string.
Try to use Mid\$,Left\$,Right\$
Cheers
0

Author Commented:
Thanks Boss
0

Commented:
Hehe...

I know but i allways forget ...;)

If you use the \$ functions you gain ~30% Speed ....
0

IT OperationsCommented:
0

Author Commented:
Sorry. It did solve the problem. I didn't know that made a difference

Sorry Glenelly22
0

Commented:
He gets more Points for an "A" then for a "B"

Usually only give a B if there are some open issues. Give a C if its only a "very general" hint for what to use...
like :
"A": Use mid(mystring,5)

"B" : Use mid

"C" : Use string functions

Well kinda in this direction  ;)

0

IT OperationsCommented:
rdrunner: excelent explanation LOL.
0

## Featured Post

• 3
• 3
• 2
• +2
Tackle projects and never again get stuck behind a technical roadblock.