Results 1 to 4 of 4

Thread: User-defined string formats

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    How do you Create your own user-defined string formats.
    I need to take string variable of x number of characters and pad with spaces so its length is always 25 characters. I would like to use a Format command and according to the Help file I can use the "@" symbol to represent a character placeholder, but it wont work.

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    Thanks for the reply, but not quite what I'm after.
    What I am trying to do is:
    A$="abcdefghijkl" 'Test input string
    B$=format (A$,"!@@@@@") ' Keep first five characters and discard remaining.
    debug.print B$ 'Print result

    Maybe I need to just read 5 characters fron left side then fill remaining 15 character positions with spaces.

    Any sugestions?

    Originally posted by Buzby:
    If you define the string fixed length;

    eg

    Dim MyString As String * 25

    it will always be 25 characters long (padded with spaces).

    The Format command should work

    eg;

    format("hello","!@@@@@@@@@@")

    would return "hello" followed by 5 spaces - if you leave the ! out it would return 5 spaces followed by "hello".

    Does this help?


  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Left$(A, 5) will give "abcde"

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    If you define the string fixed length;

    eg

    Dim MyString As String * 25

    it will always be 25 characters long (padded with spaces).

    The Format command should work

    eg;

    format("hello","!@@@@@@@@@@")

    would return "hello" followed by 5 spaces - if you leave the ! out it would return 5 spaces followed by "hello".

    Does this help?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width