Results 1 to 5 of 5

Thread: [*resolved] formatting a string...

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    [*resolved] formatting a string...

    I have a string and I want to make sure that the string is 6 characters long. If it's smaller, my program should put "0" for the missing characters. For example, "AA" would be "AA0000". This would be easy if this was a number, because the Format function would do it. But it doesnt work with strings. Is there a function similar to the Format function for this purpose?
    Last edited by MrPolite; Feb 1st, 2003 at 06:55 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Can't you do something similar to this:

    if mystring.Length < 6 then
    for mystring.Length to 6
    mystring += "0"
    next
    end if

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by hellswraith
    Can't you do something similar to this:

    if mystring.Length < 6 then
    for mystring.Length to 6
    mystring += "0"
    next
    end if
    yeah I did something like that, but I was just wondering if there is a function for these kinds stuff. sounds like there isnt...
    thanks
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Junior Member
    Join Date
    Jan 2003
    Location
    Seattle, WA
    Posts
    17
    How about
    VB Code:
    1. MsgBox("AA".PadRight(6, "0"))
    ?

  5. #5

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by FireRabbit
    How about
    VB Code:
    1. MsgBox("AA".PadRight(6, "0"))
    ?
    exactly what I was looking for thanks!
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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