General Category > Support Questions
Pulling a string from a CompactLogix...
Archie:
Add this line of code at the first line of the ExtractString function, then see what is in the Visual Studio Output Window:
Console.WriteLine("Value as Hex string=" & s)
JasonT:
Getting an error that says...
--- Quote ---Severity Code Description Project File Line Suppression State
Error BC30389 's' is not accessible in this context because it is 'Friend'. 58 Active
--- End quote ---
Archie:
Did you put the code like this:
--- Code: ---Private Function ExtractString(ByVal s As String) As String
Console.WriteLine("Value as Hex string=" & s)
Dim bytes((s.Length / 2) - 1) As Byte
For i = 0 To (s.Length / 2) - 1
bytes(i) = Byte.Parse(s.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber)
Next
Dim StringLength As Integer = BitConverter.ToInt32(bytes, 0)
Dim StringResult As String = System.Text.Encoding.Default.GetString(bytes, 4, bytes.Length - 4)
Return StringResult
End Function
--- End code ---
JasonT:
I was a bonehead...lol...I didn't put it in the right place.
As for the Output it is saying the same thing as before that the destination array is not long enough
Archie:
In the output Window you should also get
Value as Shex String=?????
I'm wanting to see what the value in hex format is,
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version