Data Values

C

cmdolcet69

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.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)
 
K

Keith G Hicks

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

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

Herfried K. Wagner [MVP]

cmdolcet69 said:
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.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

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.Substring' to extract a part of the string.
 
R

Rich P

Maybe you could try this - see if it works:

Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf).Replace("[]", "")

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

Rich
 
C

cmdolcet69

cmdolcet69 said:
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.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

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.Substring' to extract a part of the string.

You are correct it is the last character displayed in the "" how can I
get ride of any character [] in my string
 
J

Jack Jackson

cmdolcet69 said:
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.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

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.Substring' to extract a part of the string.

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("[]", "")
 
J

James Hahn

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.substring(0, STRData.length - 1)

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

STRdata = STRdata.TrimEnd(Nothing)

cmdolcet69 said:
cmdolcet69 said:
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.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)

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.Substring' to extract a part of the string.

You are correct it is the last character displayed in the "" how can I
get ride of any character [] in my string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top