|
-
Feb 4th, 2009, 01:12 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Can't concatenate to string
Code:
Dim a As String = ""
Dim x As Integer = 0
Dim y As String = ""
Dim z As Integer = 0
Dim w As String = ""
For x = 0 To 9
z = CInt(Val("&H" & x.ToString("00")))
w = Chr(z).ToString
a = a & w
w = Int(x / 10).ToString
a = a & w
w = (x Mod 10).ToString
a = a & w
Next
In debugging I can see that w gets the expected values, but they aren't concatenated to a.
I can maybe see the 1st concatenation being a problem as w=Chr(0) is Nul, and other values are non-printable/control codes-but why does that stop the other concatenations?
If I remove the 1st concatenation then I get the expected values-but if I include it then I get no concatenation from any of the lines.
Of course I would like to know why this is happening, but even if you can't explain that maybe you can suggest another approach.
What I'm trying to do is build a translation table for COBOL packed fields. Those store digits in nybbles so I'm trying to build a table that includes the character represented by each combination of digits followed by the string containing those two digits (e.g. &H00 = the two digit string "00", &H01 = the two digit string "01", etc.). I'd then use IndexOf to find the character that represents the hex code, and Substring to return the next two characters-the 'decoded' hex.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|