If this is going to display on the web, try this character: 	 . You can also try putting \t in place of the tab.
hth
valkyrie_nc
Main Topics
Browse All TopicsI need to insert spaces/Tabs into a string so that certain items will line up into columns displayed. For example, here is what my strings currently look like when displayed:
John Smith Asheville,NC
Sally Rebecca Johnson Pittsburgh,PA
And here is how I would like my strings to look:
John Smith Asheville,NC
Sally Rebecca Johnson Pittsburgh,PA
Here is some code that I've tried with no success:
'** Try #1
Dim thePerson as String = theName & " " & theCity
Response.write(thePerson)
'** Try #2
Dim theLength as Integer = len(theName)
Dim i as integer = 0
For i = 0 to (50-theLength)
theName = theName & " "
'** Also Tried: theName = theName & Chr(32)
Next
thePerson = theName & theLocation ' Note: Result is still "John Smith Asheville NC"
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I always use a table to line things up
It won't look like a table, but it will do the trick.
It's a little more typing, but very versatile especially when you want to then change the column width.
' Here's a crude example
Public Sub DoThang()
Dim strName1 As String = "John Smith"
Dim strAddr1 As String = "Asheville, NC"
Dim strName2 As String = "Sally Rebecca Johnson"
Dim strAddr2 As String = "Pittsburgh, PA"
Response.Write("<TABLE WIDTH='50%' BORDER='0'>")
Response.Write("<TR><TD>Na
Response.Write("<TR><TD>" + strName1 + "</TD><TD>" + strAddr1 + "</TD></TR>")
Response.Write("<TR><TD>" + strName2 + "</TD><TD>" + strAddr2 + "</TD></TR>")
Response.Write("</TABLE>")
End Sub
Thank you all for your quick responses and feedback. Please allow me to elaborate on why I need this solution: I'm using an AJAX component which as you type a person's name in a textbox, suggestions appear below the textbox. You can then push the down key to select any of the suggestions. As you go through the suggestions, the text in the textbox is populated with the value.
x_com: You solution is the closest to what I need. It puts spaces between the name and the city. However, even though I'm putting (50 - len(theName)) spaces between the name and the city, everything is still not lining up exactly. I think this may be because although I have the same number of characters between the name and city, the width of each name varies based on the characters in it. (ex: "Illian" takes up less space on the screen then "Chadly"). The other issue with your solution is that when you hover of the suggestion and the textbox is filled with the suggestion, the textbox shows the .
valkyrie_nc: I tried 	 instead of but it didn't seem to work. :( This is a web-based problem so I don't think the "/t" is applicable.
amit_g: You suggestion didn't create any spaces at all. It looks like it should..but it isn't. For some reason the system is trimming the spaces. :(
Triskelion: because the string is used to populate an AJAX component, I can't use tables in it.
Thank you all again for your help...if you have any other suggestions I would be most grateful.
Business Accounts
Answer for Membership
by: x_comPosted on 2007-08-17 at 13:16:26ID: 19719995
Dear Shiseiryu1,
t(intTotal , " ")," "," ")
Try this instead:
eg:
str = "John Smith" & ReturnTab(50) & "Asheville NC"
Tab Function:
Function ReturnTab(intTotal as integer) as String
Return Replace("".ToString.PadLef
End Function
Or amend your previous code, just add " " for space.
eg:
theName = theName & " "