Text.Substring

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

    #1

    Text.Substring

    Dim mystring As String
    mystring = txtInputValues. Text
    mystring.Substr ing(mystring.Le ngth - 3)


    I want my mystring to display the last 3 from the txtinputValue.t ext
    string. What im I doing wrong?
  • Patrice

    #2
    Re: Text.Substring

    This is a function that returns a new string...

    --
    Patrice

    "cmdolcet69 " <colin_dolcetti @hotmail.coma écrit dans le message de news:
    5f005d16-4e93-48a9-aca1-d987fddd70c6...l egroups.com...
    Dim mystring As String
    mystring = txtInputValues. Text
    mystring.Substr ing(mystring.Le ngth - 3)
    >
    >
    I want my mystring to display the last 3 from the txtinputValue.t ext
    string. What im I doing wrong?

    Comment

    • Armin Zingler

      #3
      Re: Text.Substring

      "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
      Dim mystring As String
      mystring = txtInputValues. Text
      mystring.Substr ing(mystring.Le ngth - 3)
      >
      >
      I want my mystring to display the last 3 from the txtinputValue.t ext
      string. What im I doing wrong?
      Note that SubString is a function. You are ignoring it's return value.


      Armin

      Comment

      • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

        #4
        RE: Text.Substring

        In addition to what the others said, make sure you add a check for the length
        of mystring. You will get a runtime error if the length is less than three.

        "cmdolcet69 " wrote:
        Dim mystring As String
        mystring = txtInputValues. Text
        mystring.Substr ing(mystring.Le ngth - 3)
        >
        >
        I want my mystring to display the last 3 from the txtinputValue.t ext
        string. What im I doing wrong?
        >

        Comment

        • Andrew Morton

          #5
          Re: Text.Substring

          cmdolcet69 wrote:
          Dim mystring As String
          mystring = txtInputValues. Text
          mystring.Substr ing(mystring.Le ngth - 3)
          >
          >
          I want my mystring to display the last 3 from the txtinputValue.t ext
          string. What im I doing wrong?
          Imports VB=Microsoft.Vi sualBasic

          Dim mystring as String=VB.Right (txtInputValues .Text, 3)

          Andrew


          Comment

          • Cor Ligthert[MVP]

            #6
            Re: Text.Substring

            Andrew,

            There is no import needed for Microsoft.Visua lBasic,

            It is standard in the project properties

            Cor

            "Andrew Morton" <akm@in-press.co.uk.inv alidschreef in bericht
            news:eYsSlzShIH A.4712@TK2MSFTN GP04.phx.gbl...
            cmdolcet69 wrote:
            > Dim mystring As String
            > mystring = txtInputValues. Text
            > mystring.Substr ing(mystring.Le ngth - 3)
            >>
            >>
            >I want my mystring to display the last 3 from the txtinputValue.t ext
            >string. What im I doing wrong?
            >
            Imports VB=Microsoft.Vi sualBasic
            >
            Dim mystring as String=VB.Right (txtInputValues .Text, 3)
            >
            Andrew
            >

            Comment

            • Andrew Morton

              #7
              Re: Text.Substring

              Cor Ligthert[MVP] wrote:
              There is no import needed for Microsoft.Visua lBasic,
              >
              It is standard in the project properties
              I tend to do that because it's easier to qualify it as VB.Right rather than
              Microsoft.Visua lBasic.Right. Otherwise the VB compiler in VS2003 can see it
              as a window/form property rather than the Right string function from VB. (Or
              maybe it only does that with Left, but for symmetry I do it with Right too.)

              Andrew


              Comment

              Working...