I am using EPPLUS to retrieve string values from Excel. The strings take the form:
“117
60%
A”
and I split them at the linebreaks. This worked perfectly normal when I used Interop to retrieve the values. But I switched to EPPLUS because Interop is rather slow.
But suddenly the Parse method fails because the 60% does contain some additional …strings. They look and print normal, but the Visual Sutdio editor shows me that the string takes the form: ‘ “60%” & vbCr & “” ‘. What is the meaning of the “&”. Normally it would show a string concenation, but that makes not too much sense.
Does anyone have an Idea about how to detect this problem?
Code:
dim TestString="117
60%
A"
Dim Splitstring() As String = Split(Value, Chr(10))
for i=0 to splitstring.length-1
debug.print(Splitstring(i))
next
The reason is that you split only with chr(10) = LF while the CR (chr(13)) remains in your string. Windows uses CRLF (13,10) as a line terminator – a relic from the days of the terminals.
try:
This way it doesn’t matter if there is a CR or not (ie. Linux text files) that are being parsed. Hope this helps.