Click here to Skip to main content
15,124,736 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Name : Mohammed
Age : 25
Sex : Male

I need output like

Mohammed 25 Male

if you see, i want Mohammed Should be first, after that there should 7 white spaces before 25(age) and there should be 12 white spaces between 25(age) and Make(sex)

Need to define the number of white spaces between words?

Values i will get input from textbox.
What is the issue?
thajudeen301190 14-Sep-14 1:49am
There is some pre-formatted values in unix.
Here people are doing some mistakes while editing in the unix.
I am doing that in, just copy paste to unix.
So no mistakes will occur..

Unix space and tab both are considerable, so here we have to use space.
Between first column and second column there is 9 space.
Between Second and third column there is 12 space.

How to do in any idea
thajudeen301190 14-Sep-14 1:56am
cnobj =
cmd.Connection = cnobj
cmd.CommandText = "select QM_NAME from TABLE where BOX = '" & ComboBox1.Text.Trim & "'"
Dim dr As OleDbDataReader = cmd.ExecuteReader
While dr.Read
Dim mada As String = TextBox1.Text
Dim strda As String = ComboBox2.Text
Dim endda As String = ComboBox3.Text
RichTextBox1.AppendText(dr.Item(0) & mada & strda & endda & Environment.NewLine)
End While

You can see i am appending data mada strda and endda, so need some space between mada and strda

apple 15 2004
mango 15 2004
anar 15 2004
grapes 15 2004

If i define space fixed space, above output will come, but it is wrong.
So, my question is 15th character must be my second column and 22nd character should be my third column
Why those 7 and 25 spaces? Your sample does not show them. And what's the problem?
Anyway, it all does not seem to make any sense. Why not doing something more useful?

1 solution

Why not use PadRight?

Example with strings called first, second and third.

first.PadRight(15) + second.PadRight(7) + third

The first string is padded out to 15 characters, the second string is padded out to 7 characters positioning it at column 22 (15 + 7 = 22).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900