Data Values

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

    Data Values

    I am using the following to gwt the return value from the serial port
    "mabtRxBuf"

    I declare my STRdata as a global string and when the code is executed
    I get the following for the STRdata

    STRdata = "0.10[]" how can i get rid of the [] in my string?


    Dim enc As New System.Text.ASC IIEncoding
    STRdata = enc.GetString(m abtRxBuf)
  • Keith G Hicks

    #2
    Re: Data Values

    This will replace all instances of "[]" with "" in your string.

    STRdata = Replace(STRdata , "[]", "")

    "cmdolcet69 " <colin_dolcetti @hotmail.comwro te in message
    news:84b2f4d6-d3bc-49b0-b229-0cc51ef899da@z7 2g2000hsb.googl egroups.com...
    I am using the following to gwt the return value from the serial port
    "mabtRxBuf"
    >
    I declare my STRdata as a global string and when the code is executed
    I get the following for the STRdata
    >
    STRdata = "0.10[]" how can i get rid of the [] in my string?
    >
    >
    Dim enc As New System.Text.ASC IIEncoding
    STRdata = enc.GetString(m abtRxBuf)

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Data Values

      "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb:
      >I am using the following to gwt the return value from the serial port
      "mabtRxBuf"
      >
      I declare my STRdata as a global string and when the code is executed
      I get the following for the STRdata
      >
      STRdata = "0.10[]" how can i get rid of the [] in my string?
      >
      >
      Dim enc As New System.Text.ASC IIEncoding
      STRdata = enc.GetString(m abtRxBuf)
      Does the string really end with the characters "[]" or is the last character
      displayed as a rectangle glyph? If the latter is the case, what's the
      character code of the last character? You could use
      'String.Left'/'String.Substri ng' to extract a part of the string.

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

      Comment

      • Rich P

        #4
        Re: Data Values

        Maybe you could try this - see if it works:

        Dim enc As New System.Text.ASC IIEncoding
        STRdata = enc.GetString(m abtRxBuf).Repla ce("[]", "")

        As long as this is text data - you should be able to parse out the [].

        Rich

        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • cmdolcet69

          #5
          Re: Data Values

          On Aug 26, 4:53 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
          h...@gmx.atwrot e:
          "cmdolcet69 " <colin_dolce... @hotmail.comsch rieb:
          >
          I am using the following to gwt the return value from the serial port
          "mabtRxBuf"
          >
          I declare my STRdata as a global string and when the code is executed
          I get the following for the STRdata
          >
          STRdata = "0.10[]" how can i get rid of the [] in my string?
          >
          Dim enc As New System.Text.ASC IIEncoding
          STRdata = enc.GetString(m abtRxBuf)
          >
          Does the string really end with the characters "[]" or is the last character
          displayed as a rectangle glyph? If the latter is the case, what's the
          character code of the last character? You could use
          'String.Left'/'String.Substri ng' to extract a part of the string.
          >
          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
          You are correct it is the last character displayed in the "" how can I
          get ride of any character [] in my string

          Comment

          • Jack Jackson

            #6
            Re: Data Values

            On Wed, 27 Aug 2008 05:15:37 -0700 (PDT), cmdolcet69
            <colin_dolcetti @hotmail.comwro te:
            >On Aug 26, 4:53 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
            >h...@gmx.atwro te:
            >"cmdolcet69 " <colin_dolce... @hotmail.comsch rieb:
            >>
            >I am using the following to gwt the return value from the serial port
            "mabtRxBuf"
            >>
            I declare my STRdata as a global string and when the code is executed
            I get the following for the STRdata
            >>
            STRdata = "0.10[]" how can i get rid of the [] in my string?
            >>
            Dim enc As New System.Text.ASC IIEncoding
            STRdata = enc.GetString(m abtRxBuf)
            >>
            >Does the string really end with the characters "[]" or is the last character
            >displayed as a rectangle glyph? If the latter is the case, what's the
            >character code of the last character? You could use
            >'String.Left '/'String.Substri ng' to extract a part of the string.
            >>
            >--
            > M S Herfried K. Wagner
            >M V P <URL:http://dotnet.mvps.org/>
            > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
            >
            >You are correct it is the last character displayed in the "" how can I
            >get ride of any character [] in my string
            If str.EndsWith("[]" Then
            ' Get rid of last two chars if they are []
            str = str.Substring(0 , str.Length-2)
            End If

            or

            ' Get rid of all occurences of []
            str = str.Replace("[]", "")

            Comment

            • James Hahn

              #7
              Re: Data Values

              The box represents a non-ascii character in the string, probably a line feed
              or carriage-return. Use StrData.Length to confirm that the string is
              actually one character longer than the ASCII characters you can see. If it
              is consistently one character longer than it should be then use the
              substring method to extract everything except the last character.

              STRdata = STRdata.substri ng(0, STRData.length - 1)

              Depending on the contents of the string, you might be able to use

              STRdata = STRdata.TrimEnd (Nothing)

              "cmdolcet69 " <colin_dolcetti @hotmail.comwro te in message
              news:f6df5190-dfc2-4f49-84d3-1777fe7498ed@y3 8g2000hsy.googl egroups.com...
              On Aug 26, 4:53 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
              h...@gmx.atwrot e:
              >"cmdolcet69 " <colin_dolce... @hotmail.comsch rieb:
              >>
              >I am using the following to gwt the return value from the serial port
              "mabtRxBuf"
              >>
              I declare my STRdata as a global string and when the code is executed
              I get the following for the STRdata
              >>
              STRdata = "0.10[]" how can i get rid of the [] in my string?
              >>
              Dim enc As New System.Text.ASC IIEncoding
              STRdata = enc.GetString(m abtRxBuf)
              >>
              >Does the string really end with the characters "[]" or is the last
              >character
              >displayed as a rectangle glyph? If the latter is the case, what's the
              >character code of the last character? You could use
              >'String.Left '/'String.Substri ng' to extract a part of the string.
              >>
              >--
              > M S Herfried K. Wagner
              >M V P <URL:http://dotnet.mvps.org/>
              > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
              >
              You are correct it is the last character displayed in the "" how can I
              get ride of any character [] in my string

              Comment

              Working...