Solved

vb number format

Posted on 2004-04-23
8
400 Views
Last Modified: 2010-04-17
I have a number that looks like this


00001230

what I need is a code that will format it like this


12.30

now sometimes the number will be

00231232

should be
2312.32

meaning always two on the right and 4 on the left

any ideas
0
Comment
Question by:peanut1010
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 6

Expert Comment

by:MannSoft
ID: 10902782
You could use the FormatNumber() function.  I think maybe:

FormatNumber(TheNumber, 2, 0, 0, 0)
0
 

Author Comment

by:peanut1010
ID: 10902783
also if it is like this


00000012

should be 0.12
0
 
LVL 6

Expert Comment

by:MannSoft
ID: 10902804
In that case, FormatNumber(TheNumber, 2, -1, 0, 0) should do it
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:peanut1010
ID: 10902863
it is putting the the numbers 1st and leaving the .0000


not

00000120

0.120

doing

120.00
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 10902888
Why not simply divide by 100?
0
 

Author Comment

by:peanut1010
ID: 10902919
because it would make it 1.2
divide by 1000 would still make it

120,000
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 10904529
Private Sub Command1_Click()
    Dim Samples As Variant
    Dim i As Integer
   
    Samples = Array("00001230", "00231232", "00000012")
    For i = 0 To UBound(Samples)
        Debug.Print Format$(Samples(i) / 100, "0.00")
    Next i
End Sub
0
 

Accepted Solution

by:
rajsekar earned 25 total points
ID: 10906177
try this

Val(MID("00001230",1,6))  & "." & Val(MID("00001230",7,2))
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

825 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