unwanted characters in a textbox

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
C

cmdolcet69

I have a value bieng added into my array that displays correctly in
the textbox as 0.10 however when i read from my array into an excel
spreadsheet I get the value 0.10 [][] how can I get rid of the [][]
characters????
 
cmdolcet69 said:
I have a value bieng added into my array that displays correctly in
the textbox as 0.10 however when i read from my array into an excel
spreadsheet I get the value 0.10 [][] how can I get rid of the [][]
characters????

Is your textbox a multiline textbox? If so the chars you see may be a
carriage return / line feed. Perhaps showing some code might help.

LS
 
cmdolcet69 said:
I have a value bieng added into my array that displays correctly in
the textbox as 0.10 however when i read from my array into an excel
spreadsheet I get the value 0.10 [][] how can I get rid of the [][]
characters????
Is your textbox a multiline textbox? If so the chars you see may be a
carriage return / line feed. Perhaps showing some code might help.

LS
 
cmdolcet69 said:
I have a value bieng added into my array that displays correctly in
the textbox as 0.10 however when i read from my array into an excel
spreadsheet I get the value 0.10 [][] how can I get rid of the [][]
characters????

Is your textbox a multiline textbox? If so the chars you see may be a
carriage return / line feed. Perhaps showing some code might help.

LS

There really isn;t any code all i do is pull the serial information
from a controller....what would be the best way to get those [] [] off?
 
cmdolcet69 said:
I have a value bieng added into my array that displays correctly in
the textbox as 0.10 however when i read from my array into an excel
spreadsheet I get the value 0.10 [][] how can I get rid of the [][]
characters????

Is your textbox a multiline textbox? If so the chars you see may be a
carriage return / line feed. Perhaps showing some code might help.

LS

Lloyd, here the code the STRdata is tring to convert the
end.GetString(mabtRxbuf) but the string value coming over is for
example "0.10[][]

what is going on?


Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer
Dim strdata as string

' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else
' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)


Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)


If iRc = 0 Then
' Read Error
Throw New ApplicationException( _
"ReadFile error " & iRc.ToString)
Else
'commmented out because of issues with overflow
' Handles timeout or returns input chars
'If iReadChars < Bytes2Read Then
'Throw New IOTimeoutException("Timeout error")
'Else
mbWaitOnRead = True
Return (iReadChars)
End If
End If
End If
End Function
 
first it would be wise to figure out what the characters are

in excel enter the formula "=code(right(yourcell),1)) this will tell you the
character code for the last [] (replace youcell with the cell your data is in)

to know the fore last character use "=code(mid(yourcell,len(yourcell)-1,1))
(not 100% sure about the -1, might be -2... excel sometimes uses 1 as floor
and sometimes not)

If you get 10 and 13 you could enable wordwrap in excel (cellproperties,
second tab, one of the 3 checkboxes at the botom, and try again)
 
cmdolcet69 said:
cmdolcet69 said:
I have a value bieng added into my array that displays correctly in
the textbox as 0.10 however when i read from my array into an excel
spreadsheet I get the value 0.10 [][] how can I get rid of the [][]
characters????
Is your textbox a multiline textbox? If so the chars you see may be a
carriage return / line feed. Perhaps showing some code might help.

LS

Lloyd, here the code the STRdata is tring to convert the
end.GetString(mabtRxbuf) but the string value coming over is for
example "0.10[][]

what is going on?


Public Function ReadValidatedData(ByVal Bytes2Read As Integer) As
Integer
Dim iReadChars, iRc As Integer
Dim strdata as string

' If Bytes2Read not specified uses Buffersize
If Bytes2Read = 0 Then Bytes2Read = miBufferSize
If mhRS = -1 Then
Throw New ApplicationException( _
"Please initialize and open port before using this
method")
Else
' Creates an event for overlapped operations
If meMode = Mode.Overlapped Then
pHandleOverlappedRead(Bytes2Read)
Else
' Non overlapped mode
ReDim mabtRxBuf(Bytes2Read - 1)
iRc = ReadFile(mhRS, mabtRxBuf, Bytes2Read,
iReadChars, Nothing)


Dim enc As New System.Text.ASCIIEncoding
STRdata = enc.GetString(mabtRxBuf)


If iRc = 0 Then
' Read Error
Throw New ApplicationException( _
"ReadFile error " & iRc.ToString)
Else
'commmented out because of issues with overflow
' Handles timeout or returns input chars
'If iReadChars < Bytes2Read Then
'Throw New IOTimeoutException("Timeout error")
'Else
mbWaitOnRead = True
Return (iReadChars)
End If
End If
End If
End Function

You will need to find out what the two extra characters are.

In VS immediate window use:

?asc(STRdateSubstring(STRDataLength-1,1))
and
asc(songname.Substring(SongName.Length-2,1))

If the values returned are 13 and 10 you are getting a CR/LF
combination. If not this will help determine what the characters are.

LS
 
Back
Top