substring, left, right function ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Agnes

    substring, left, right function ?

    in .net , any left function ??
    or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
    Thanks


  • One Handed Man \( OHM - Terry Burns \)

    #2
    Re: substring, left, right function ?

    Dim a As String = "ABCDEF"

    Debug.WriteLine (a.Substring(0, 5))

    'Returns ABCDE


    --

    OHM ( Terry Burns )
    . . . One-Handed-Man . . .
    If U Need My Email ,Ask Me

    Time flies when you don't know what you're doing

    "Agnes" <agnes@dynamict ech.com.hk> wrote in message
    news:uHcQQ0xlEH A.3524@TK2MSFTN GP12.phx.gbl...[color=blue]
    > in .net , any left function ??
    > or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
    > Thanks
    >
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: substring, left, right function ?

      * "Agnes" <agnes@dynamict ech.com.hk> scripsit:[color=blue]
      > in .net , any left function ??
      > or I should use Microsoft.Visua lBasic.Left(myS tring, 5)[/color]

      I suggest to use VB.NET's 'Left' function because it is more descriptive
      than the string's 'Substring' method.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: substring, left, right function ?

        Agnes,
        The Left function in .NET is Microsoft.Visua lBasic.Strings. Left!

        If you use Strings.Left you may want to use an Import alias on
        Microsoft.Visua lBasic.

        Imports VB = Microsoft.Visua lBasic

        Dim myString As String
        myString = VB.Left(myStrin g, 5)

        Especially in Window Forms, as Left is a property of Control.

        An alternative to Microsoft.Visua lBasic.Strings is the methods on String
        itself (such as String.SubStrin g). I normally use String.SubStrin g instead
        of Strings.Left, however both are equally valid.

        The one caveat I recommend is do not mix the VB Strings functions with the
        String methods, as VB Strings are 1 based indexes & the String methods are 0
        based indexes.

        Hope this helps
        Jay

        "Agnes" <agnes@dynamict ech.com.hk> wrote in message
        news:uHcQQ0xlEH A.3524@TK2MSFTN GP12.phx.gbl...[color=blue]
        > in .net , any left function ??
        > or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
        > Thanks
        >
        >[/color]


        Comment

        • Agnes

          #5
          Re: substring, left, right function ?

          I understand now, I will use substring instead.
          Thanks ALL

          "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> ¦b¶l¥ó
          news:%23wXwsB0l EHA.1672@TK2MSF TNGP14.phx.gbl ¤¤¼¶¼g...[color=blue]
          > Agnes,
          > The Left function in .NET is Microsoft.Visua lBasic.Strings. Left!
          >
          > If you use Strings.Left you may want to use an Import alias on
          > Microsoft.Visua lBasic.
          >
          > Imports VB = Microsoft.Visua lBasic
          >
          > Dim myString As String
          > myString = VB.Left(myStrin g, 5)
          >
          > Especially in Window Forms, as Left is a property of Control.
          >
          > An alternative to Microsoft.Visua lBasic.Strings is the methods on String
          > itself (such as String.SubStrin g). I normally use String.SubStrin g[/color]
          instead[color=blue]
          > of Strings.Left, however both are equally valid.
          >
          > The one caveat I recommend is do not mix the VB Strings functions with the
          > String methods, as VB Strings are 1 based indexes & the String methods are[/color]
          0[color=blue]
          > based indexes.
          >
          > Hope this helps
          > Jay
          >
          > "Agnes" <agnes@dynamict ech.com.hk> wrote in message
          > news:uHcQQ0xlEH A.3524@TK2MSFTN GP12.phx.gbl...[color=green]
          > > in .net , any left function ??
          > > or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
          > > Thanks
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...