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

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
Asked:
glenelly22
  • 3
  • 3
  • 2
  • +2
1 Solution
 
TimCotteeCommented:
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
 
rengaraajCommented:
a = "abcdefgh"
b = Mid(a, 1, 4)
c = Mid(a, 5, 4)
Print b, c
0
 
rdrunnerCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Richie_SimonettiIT OperationsCommented:
Note to all:
Not use Mid, left or right function with string.
Try to use Mid$,Left$,Right$
Cheers
0
 
glenelly22Author Commented:
Thanks Boss
0
 
rdrunnerCommented:
Hehe...

I know but i allways forget ...;)


If you use the $ functions you gain ~30% Speed ....
0
 
Richie_SimonettiIT OperationsCommented:
Why a "B" grade?, didn't it solves your problem?
0
 
glenelly22Author Commented:
Sorry. It did solve the problem. I didn't know that made a difference

Sorry Glenelly22
0
 
rdrunnerCommented:
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
 
Richie_SimonettiIT OperationsCommented:
rdrunner: excelent explanation LOL.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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