Simple question from an old COBOLer / VB newbie:
What is a concise way to convert an integer to a string such that the resulting value in the string is 4 characters long, right adjusted with leading zeros suppressed (converted to spaces)?
The value will vary from 1 to 9999, and I want it to appear right-adjusted. For example, 1 would appear as bbb1 and 10 would appear as bb10, where the b represents a space.
FYI, here's the current statement that I am playing with (which isn't doing this and will need to be changed to reflect your answer):
Dim lvi As ListViewItem = _
ListView1.Items.Add((i + 1).ToString("D4"), 0)
In COBOL, you would have A defined as PIC 9(4) and B defined as PIC ZZZ9 or Z(4), and you would just MOVE A TO B or you would use an INSPECT statement, etc.
I have searched for the answer and haven't found it.
Thanks,
AustinOne
What is a concise way to convert an integer to a string such that the resulting value in the string is 4 characters long, right adjusted with leading zeros suppressed (converted to spaces)?
The value will vary from 1 to 9999, and I want it to appear right-adjusted. For example, 1 would appear as bbb1 and 10 would appear as bb10, where the b represents a space.
FYI, here's the current statement that I am playing with (which isn't doing this and will need to be changed to reflect your answer):
Dim lvi As ListViewItem = _
ListView1.Items.Add((i + 1).ToString("D4"), 0)
In COBOL, you would have A defined as PIC 9(4) and B defined as PIC ZZZ9 or Z(4), and you would just MOVE A TO B or you would use an INSPECT statement, etc.
I have searched for the answer and haven't found it.
Thanks,
AustinOne