Results 1 to 3 of 3

Thread: number to fixed width right aligned string?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Posts
    164

    number to fixed width right aligned string?

    Hi All
    I want to know if there is any function in VB6 which is like STR function in SQL Server.
    STR function takes three arguments viz. number to be formatted, width of resulting string and decimal places required.
    I want such function in VB6 where if I supply number, total width and decimal places required, I will get a string right aligned within specified width. If number is smaller, it must get padded with spaces.
    I hope VB6 must be having such a basic function.
    Please help
    Thanx

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: number to fixed width right aligned string?

    Nope, but it's easy enough to write one...

    Use Format (or Round) to get the number of decimal places you want, then use the Space function (using Desiredlength - Len(roundednumber)) to create the spaces in front of it.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Posts
    164

    Re: number to fixed width right aligned string?

    Thank you.
    I am doing the same now.

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