?
Solved

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

Posted on 2003-03-06
10
Medium Priority
?
202 Views
Last Modified: 2010-05-01
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
Comment
Question by:glenelly22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 8079532
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
 

Expert Comment

by:rengaraaj
ID: 8079624
a = "abcdefgh"
b = Mid(a, 1, 4)
c = Mid(a, 5, 4)
Print b, c
0
 
LVL 11

Expert Comment

by:rdrunner
ID: 8080728
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8081219
Note to all:
Not use Mid, left or right function with string.
Try to use Mid$,Left$,Right$
Cheers
0
 

Author Comment

by:glenelly22
ID: 8081238
Thanks Boss
0
 
LVL 11

Expert Comment

by:rdrunner
ID: 8081411
Hehe...

I know but i allways forget ...;)


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

Expert Comment

by:Richie_Simonetti
ID: 8081743
Why a "B" grade?, didn't it solves your problem?
0
 

Author Comment

by:glenelly22
ID: 8106916
Sorry. It did solve the problem. I didn't know that made a difference

Sorry Glenelly22
0
 
LVL 11

Expert Comment

by:rdrunner
ID: 8109260
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8110672
rdrunner: excelent explanation LOL.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question