Padding Strings into Textbox

Posted on 2008-11-12
Medium Priority
Last Modified: 2012-05-05
I'm trying to figure out how to Pad fields in strings, basically I have information that needs to be separated by a certain amount of spaces.  I have several text fields that all have different data and each will be different on the amount of spaces required as well may have more or less columns.

I.E. (I need this kind of format were each column is in line)
1   1098774978                  79787440604604665540                     44587749        7790014              3
34 109878                          7978744060460466                             87749              77014                  2
(Not this, if the numbered strings are shorter or longer than any others)
34 109878                  7978744060460466                     87749        77014              2
Question by:thaburner
  • 2
LVL 76

Accepted Solution

GrahamSkan earned 2000 total points
ID: 22942178
You can pad a field to a fixed length, say 10 characters

strNew = Left$(strField & space(10),10)
LVL 76

Expert Comment

ID: 22942199
Alternatively you can use fixed-length string variables

Dim strNew As String * 10
strNew = strField

Open in new window


Author Closing Comment

ID: 31516016

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question