SgDotNet
Singapore Professional .NET User Group -For Cool Developers

A vb question related to string..

Latest post 06-15-2005 4:12 PM by angelhalo. 10 replies.
  • 06-14-2005 11:59 AM

    A vb question related to string..

    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 ?

  • 06-14-2005 12:26 PM In reply to

    Re: A vb question related to string..

    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. Idea [I]

    Maung Maung

    Maung Maung
  • 06-14-2005 12:27 PM In reply to

    Re: A vb question related to string..

    You can use Substring.
    Software development made easy with Paladin RAD Framework. Save some trees, use Stickies.NET
  • 06-14-2005 1:23 PM In reply to

    Re: A vb question related to string..

     Firedancer wrote:
    You can use Substring.

    Yes, why didn't I think of that? Embarrassed [:$]

    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.

    Maung Maung

     

    Maung Maung
  • 06-14-2005 3:10 PM In reply to

    Re: A vb question related to string..

    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

  • 06-14-2005 4:37 PM In reply to

    Re: A vb question related to string..

     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 equivalent in VB or VBscript is the Mid() function.

    The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

  • 06-14-2005 5:01 PM In reply to

    Re: A vb question related to string..

     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 Geeked [8-|], 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.

    Maung Maung

    Maung Maung
  • 06-14-2005 5:27 PM In reply to

    Re: A vb question related to string..

    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..)

  • 06-14-2005 5:44 PM In reply to

    Re: A vb question related to string..

    MessageBox.Show is the VB.NET thingy. So just stick to MsgBox for VBScripting or Wscript.Echo() method to display it.

    Maung Maung

    Maung Maung
  • 06-15-2005 1:22 AM In reply to

    Re: A vb question related to string..

     angelhalo wrote:
    btw, out of topic qn, is there any attachment students using this forum ?? (I'm one lol..)
    While there are student-oriented forums in this community, we generally do not differentiate the "age groups" and push students into a nursery room. We are all here because of .NET, that's it.

    The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

  • 06-15-2005 4:12 PM In reply to

    Re: A vb question related to string..

    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

Page 1 of 1 (11 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems