microkarl Posted June 6, 2005 Posted June 6, 2005 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 Quote Donald DUCK : YOU ARE FIRED!!!
SteveoAtilla Posted June 6, 2005 Posted June 6, 2005 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 Quote 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
FYRe Posted August 19, 2005 Posted August 19, 2005 (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 August 19, 2005 by PlausiblyDamp Quote sOMEONE'S gONNA dO iT, wHY nOT yOU ?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.