Solved

vb number format

Posted on 2004-04-23
8
387 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the compatible hibernate version for spring 4.3.1 10 75
find a node in VST 2 63
groupSumClump challenge 9 98
move one pixel 4 58
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

912 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now