Padding Strings into Textbox

Posted on 2008-11-12
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
    LVL 76

    Accepted Solution

    You can pad a field to a fixed length, say 10 characters

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

    Expert Comment

    Alternatively you can use fixed-length string variables

    Dim strNew As String * 10
    strNew = strField

    Open in new window


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now