Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all,

Say I have a string strData="4567n54y454=43nv345h983", and I want to seperate them into strData_1 = "4567n54y454" (takes every thing before '='), and strData_2 = "43nv345h983" (takes every thing after '=').

Can it be done easily? I mean, my first thought would be get the position of '=' from strData, and subString it. But, is there an easier way that the same thing can be achieve with fewer code??

 

Thanks

Donald DUCK : YOU ARE FIRED!!!
Posted
Hello all,

Say I have a string strData="4567n54y454=43nv345h983", and I want to seperate them into strData_1 = "4567n54y454" (takes every thing before '='), and strData_2 = "43nv345h983" (takes every thing after '=').

Try this:

 

            dim strData_Split As String()
strData_Split = Split(strData, "=")
 

 

You then have strData_Split(0) and strData_Split(1) with the two different halves.

 

Kahuna

The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order.

Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing.

-- Vincent T. Lombardi
  • 2 months later...
Posted (edited)

Substring & IndexOf

 

--------------------------------------------------------------------------

 

Sure, that's not much of a problem. (See attached file)

Try these 2 :

 

 

"str.Substring(m, n)" :

 

where str is a string, consisting of n characters beginning with the character in position m of string :

� extract n number of characters, starting from the m th character. �

 

Eg. Dim str As String = "testing"

Dim str2 As String

str2 = str.Substring(1, 3) ' str2 has a value of "est"

 

 

 

 

"str.IndexOf(str2) " :

 

Eg. Dim str As String = "testing"

Dim str2 As String

str2 = str.IndexOf("stin") ' str2 has a value of "2"

 

 

 

[ note that in such cases, strings are numbered (from left to right), from 0,1,2,3, ...

not 1,2,3,4, .... ]

 

 

--------------------------------------------------------------------------

Substring & IndexOf.zip

Edited by PlausiblyDamp
sOMEONE'S gONNA dO iT, wHY nOT yOU ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...