Results 1 to 6 of 6

Thread: Formating percentages

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    59

    Formating percentages

    Is there an easy way to format a % into a normal number?

    For example, 55.5% into .555?

    I've written some code to do it, but it's quite a few lines so was wondering if there is a way to do it in 1-3 lines.

  2. #2

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    59

    Re: Formating percentages

    *sigh*

    I always get embarrassed by things like this :P Always trying to find the most complicated method ever.

    Thanks!

  4. #4

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Formating percentages

    very true Rhino

    I follow this in VBA Excel

    Code:
    Sub formatnumber()
        sss = "55.5%"
        MsgBox Val(Format(sss, general))
    End Sub
    Not sure if "general" will work in vb6
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Formating percentages

    And, this will remove the leading 0 from Rhino's code if that is a requirement:
    Code:
    MsgBox Format$(CSng(Replace("55.5%", "%", "")) / 100, "#.000")
    Doctor Ed

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