469,600 Members | 2,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,600 developers. It's quick & easy.

alignment of strings representing integers

I try to add strings with fixed length who are representing integers
So I have to put spaces (I guesse) before short strings(from short
integers).

F.e.
12345
1
567
5432
54328

I am convinced that I can find a methode but I guesse that there must be
a simple method given by VB.NET but that I don't know.
Thanks for any response
Aug 25 '08 #1
6 1057
Try :
http://msdn.microsoft.com/en-us/libr...g.padleft.aspx

but what you are trying to do is unclear ("add strings" ?). It will allow to
add spaces in front of your strings...

If you want to add the numeric value representing those strings, you have to
convert them and some of those values are not short integers which could be
the problem you have ?

--
Patrice

"andrews" <an*****@pandora.bea écrit dans le message de groupe de
discussion : 4g*******************@newsfe13.ams2...
I try to add strings with fixed length who are representing integers
So I have to put spaces (I guesse) before short strings(from short
integers).

F.e.
12345
1
567
5432
54328

I am convinced that I can find a methode but I guesse that there must be a
simple method given by VB.NET but that I don't know.
Thanks for any response

Aug 25 '08 #2
I was thinking to be clear but here is the information

dim Number as integer
dim str1 as string = "Value is "
dim st as string
Number = 342
st = str1 & Number.tostring
Aug 25 '08 #3
if you want your numbers to be represented like columns just use a textbox
like this

Dim r As New Random
With TextBox1
.RightToLeft = Windows.Forms.RightToLeft.Yes
.Multiline = True
.Dock = DockStyle.Fill
End With
For x = 0 To 100
TextBox1.AppendText(r.Next(0, 123456) & vbCrLf)
Next
"andrews" <an*****@pandora.bewrote in message
news:h2********************@newsfe15.ams2...
I was thinking to be clear but here is the information

dim Number as integer
dim str1 as string = "Value is "
dim st as string
Number = 342
st = str1 & Number.tostring
Aug 25 '08 #4
So it looks like the PadLeft solution could be what you are looking for.
What if you try :

Dim Number As Integer() = {1, 100, 80}
Dim str1 As String = "Value is "
For i = 0 To UBound(Number)
Debug.WriteLine(str1 & Number(i).ToString.PadLeft(10))
Next

Is this what you are looking for ? If nopt, what is the difference wiht what
you would like to get ???

--
Patrice

"andrews" <an*****@pandora.bea écrit dans le message de groupe de
discussion : h2********************@newsfe15.ams2...
I was thinking to be clear but here is the information

dim Number as integer
dim str1 as string = "Value is "
dim st as string
Number = 342
st = str1 & Number.tostring

Aug 25 '08 #5
Padleft is for me THE SOLUTION that is the most simplest
Thanks very much to everyone
Aug 25 '08 #6
andrews wrote:
I try to add strings with fixed length who are representing integers
I am convinced that I can find a methode but I guesse that there must be
a simple method given by VB.NET but that I don't know.
How about this:

Dim i as Integer = 77

? String.Format("({0,5})", i)
( 77)

HTH,
Phill W.
Aug 26 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.