For java there is String.CharAt(0) , to take the 1st char of the string (correct me if the syntax is wrong)
is there a similar method in vbScript / vb ?
VB has many string manipulation functions.
Left(strOrigin, intLen) will extract the given number of left most characters from the given string.
Right(strOrigin, intLen) will extract the given number of right most characters from the given string.
Mid(strOrigin, intStart, intLen) will extract the intLen of characters from the strOrigin starting from intStart index.
If you are using VB.NET 2005, you have to call these functions thru Strings module of the Microsoft.VisualBasic library (which is already referenced by your VB Project).
For Example:
Dim s as String = "Hello World"MessageBox.Show(Strings.Left(s,5))
The above example will display "Hello" in the messagebox.
But remember one thing when you are playing with the string datatype. String datatype in .NET is reference type and it is immutable. Excessive string manipulation will have impact on the performance. You should consider using StringBuilder if you need more complex/excessive string manipulation.
Hope it helps a little.
Maung Maung
Firedancer wrote:You can use Substring.
Yes, why didn't I think of that?
Using .NET Framework provided method are better in term of langauge portability.
You can find out the static methods of the String class in Object Browser.
hmm substring would be nice but too bad i'm doing vbscript which doesn't has this function ( I thought that it might have it ) ..
Anyway i need to break a string into many characters.. e.g using split, u can split the expression into many pieces stored in an array ( this pieces are seperated by a delimeter)
e.g t.e.s.t and the delimeter is "." , this string will be seperated into t, e, s, t...
I need to find a way that can do the same thing but without the use of adding "."
Can someone add a vbscript page in this forum ? (lol) I feel abit awkward asking vbscript questions in VB.NET page..lol
angelhalo wrote:hmm substring would be nice but too bad i'm doing vbscript which doesn't has this function ( I thought that it might have it ) ..
The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral
angelhalo wrote: hmm substring would be nice but too bad i'm doing vbscript which doesn't has this function ( I thought that it might have it ) .. Anyway i need to break a string into many characters.. e.g using split, u can split the expression into many pieces stored in an array ( this pieces are seperated by a delimeter) e.g t.e.s.t and the delimeter is "." , this string will be seperated into t, e, s, t... I need to find a way that can do the same thing but without the use of adding "." Can someone add a vbscript page in this forum ? (lol) I feel abit awkward asking vbscript questions in VB.NET page..lol
Oh i c , you are doing the VB Scripting. Then you can reference the first post which I replied earlier as those functions can be used in VB Scripting as well as .NET programming.
oh you mean the messagebox.show ? ok thx..
btw, out of topic qn, is there any attachment students using this forum ?? (I'm one lol..)
MessageBox.Show is the VB.NET thingy. So just stick to MsgBox for VBScripting or Wscript.Echo() method to display it.
angelhalo wrote:btw, out of topic qn, is there any attachment students using this forum ?? (I'm one lol..)
MuangMaung : k thanks for da help
Icelava : ok =x I was just asking for fun, anyway i didn't notice there is a student-oriented forum o.o I'll go check it out when im free..back to work