VB6 Format Number
Why VB6 writes decimals like this : .2 instead of 0.2 it really annoys me.
How can I fix it ?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Format A Number To Text Using Format()
I'd like to take a column of numbers in excel and format them to a fixed number of text carachters with leading zeros. Example:
1 to 001
25 to 025
131 to 131
I can do this with the =text(cell, "000") in the spreadsheet, but would like to use a macro to do it for me.
Here is what I have so far:
data = ActiveCell
ActiveCell = Format(data, "000")
Loop Until ActiveCell = ""
This script does not format any of the numbers, but I know it is going through the loop. Help Please!!
Format A Number To Time Format?
I'm trying to change a number so that it shows the correct time.
E.g. I know that 1.22287694... equals 5.20 am.
Overall, I need the formula to convert that decimal number into a time format.
Anyone have any info / links ?
Format$(NUMBER, &"#.##&") Vs Format$(NUMBER, &"0.00&") Vs Format$(NUMBER, &"Currency&")
I'm just learning VB and can't seem to find out what the differences are between the three formatting options 0.00, #.##, Currency.
format$(94.445, "#.##") vs format$(94.445, "0.00") vs format$(94.45, "Currency")
I ran small program and formatted 94.445 using all three types, they all returned 94.45. I don't see a differance between 0.00, and #.##. The only noticeable differance was with currency when formatted to a text box showed the dollar sign. Can someone explain the differances? TIA
Can someone tell me how to format
basically i wanna convert from scientific notation and display only one decimal place. Is there a Format() paramter that can do this? Or do i have to do it using string manipulation.
Can you suggest me if Text4 to do this
In Text4 set
MultiLine = "True"
ScrollBars = "2 - Vertical"
I try this Format(Text4, "#,##0.0000;-#,##0.0000") but not work show this?
Id like the output in a textbox with a numerical format like this..
ive looked at the dataformat property but it doesnt provide
option for my desired output
How To Format A Number??
i want to use a format function..
but i donno how??
something like this :
how to format this number so that the result would be 0.33
how to format the result so that it would be 0.86
the result i desire is 1..
hlp me plz..
Get Number Format.
I can use the following line of code to get the Decimal symbol of the system number format:
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, Buffer, Len(Buffer))
I also want to get the digit grouping symbol, what constant must I use?
Thanks a lot for all your helps.
What Format For NUMBER?
We write for DATE "CDate" and for Currency "CCurrency" then what for Number?
Why Won't This Number Format?
This won't format? dTotGrossWeight is a double, sTotGrossWeight is a string.
I know I have used this before, what am I missing?
sTotGrossWeight = Format(dTotGrossWeight, "###,###,###,##0")
The number going in is 38572, coming out it is 38572.
I have a numbers like 3.5 and I would like them to make them 4, I mean each number that has over 0.5 to make make it to the bigger one.
1.57 = 2
1.50 = 2
1.49 = 1
How To Format This Number
can anyone show me how to format and display a number the way i want it.
for example. if i have 24.5 and i want to display as 24.50, but if i already have 24.50 or 24.51 then it means my code will have to ignore that number.
what i want it to do is just check if there is a last digit.
please note that these numbers can sometimes not be 24.5 but 2451.5 or something more.
thanks in adv
I use this:
And I get the output like this: 3.4 , what should I use to get output: 3.40 , with a zero at the end.
Format A Number
how do you format a number like this: 1 will turn into 0001, 10 will turn into 0010,etc..? is there a function that willl do this?
Format A Number
How to format a number 96% = A+?
A = InputBox("Enter the word")
If A = "broke" Then KK = 1 + KK
Format = KK("%00.00")
Text1 = KK
LL = KK / 20
Text2 = LL
i want to change the format of the number in a textbox
to have a thousand separator.
i.e. the number 12345.78 should change to 12,345.78 .
Problem is , by using format(num,"#,###")
12345.78 becomes 12346 . I want to have the decimal part as it is.
I have a product ID number that looks similar to the following.
1234 4351 0076 8902
What I would like to do is format the number dynamically through code so that it displays like this on the form.
xxxx xxxx xxxx 8902
I would appreciate any help. Thank you.
Ok i have fallowing problem: I want to convert
1 into 000001.txt
13 into 000013.txt
223 into 000223.txt
is this possible with the format() function ?
the result must be a filename with ######.txt (6 numbers)
any suggestions ?
I have an integer number that I want to display with digit groupings such as this US version:
If I use the format function with "Standard" formatting it displays:
I don't want these trailing 0's. While I could manually create a format string like "###,##0" to remove these, it assumes that the users regional settings have the comma as a digit grouping symbol (some countries use a period or no symbol at all). Is there some way to get around this?
All I want is a the ability to display an integer with digit grouping. It sounds easy, but I am having problems. Thanks!
i am tying to format a number so that is displays it without and decimal places. i have tried using, the following:
txtCellP(i).Text = FormatNumber(P(i), 0)
which gives the following ouput
however, I don't want this comma to appear.
How do i change this so the ouput is simply
Hello, I would like to format numbers that my "calculator" generate.
I would like that 7598345.78 becomes 7 598 345,78
Format - Number
anyone got any ideas of why when i apply the function
format - number (positiveNumber, "##.##"), it returns a negative number (same number as positiveNumber, just with - in front !)
I have an application that calculates a figure depending on the user inputs. The figure that is calculated is displayed in a text box. The problem I have is that I need to round down the calculated figure to the nearest 100 i.e value returned is 2361, round amount down to display 2300.
Any help would be much appreciated.
My drop down menu shows numbers 00-09 but when any of those numbers are transfered to another text box its shows as 0-9. How can I remedy this? Thanks.
How To Format Number 1 To 1.00 And 1.5 To 1.50
I guess this is an easy one but I haven't found the solution yet. I have a textbox for input. The input can be given as an integer or with decimals. I need a function that changes the input to decimal. If the input is given as 1 I would like it to be changed to 1.00 and if it is given as 1.5 I would like the function to add one zero to the end 1.50.
Is it possible to keep three decimals if the input is given with three decimals? 1.234 => 1.234
I hope you understand what I'm trying explain.
Hai, I am Ramesh,
When I was developing a frontend in vb for an Excel file.
I found that, number such as 0001 is automatically truncated to 1.
Can any one help me to solve my problem (excel auto truncation of number).
Ramesh Krishnan R
when i key in the amount like 123 in the text box it should display the
amount like 123.00
it is possible .... please help me..
How can I display a number exactly like the following? Thanks
1 000 000 000 000 000 000 000 000
Number Page Format
My question is about Word. I have four formats when I insert a number page down of the page. I want to put a specific number format in the number page. First the number of the page and left side the total number of pages. How can I do it?
Question On Format The Number
I like to be more specific and format the float number like:
How can I format it? please take a look at what I have done sofar.
Many thanks for your help,
Public Function chooseFormat(dblValue As Double) As String
Dim StrRet As String
dblTest = Abs(dblValue)
If condition Then
StrRet = Format(dblTest, "#.###e-###")
StrRet = "-" + StrRet
ElseIf dblValue > 0 Then
StrRet = Format(dblTest, "#.###e+###")
'ElseIf condition Then
'StrRet = Format(dblTest, "????")
If dblValue < 0 Then
StrRet = Format(dblTest, "#.###e-###")
StrRet = "-" + StrRet
chooseFormat = StrRet
Converting A Number Format
is there a way to convert a number like this "12:07:02" to this "12.07" using EXCEL Vb
ive tried format cell number etc that dont work is there a way to edit the cell contents or a way in which you can send key strokes in to a cell to remove the end 2 numbers and replace the ":" with a "."
Number Format Issue
I have created a file in Excel version 2003. When I try to open the file in Excel version 2000 the following error is reported by the Office Assistant:
File Error. Some number formats may have been lost.
I have tried to save the file using Save As...and then selecting Excel Version 97-2003, but the error still appears.
Is there anyway to get rid of this error without redoing the file in Excel 2000?
Is there any way to surpress this Office Assistant error message using a macro since the file seems to work fine?
Conditional Number Format?
Is there a way to set a conditional number format? For example, I am maintaining a list of phone numbers. Some of them are internal extensions that I want to appear as 'X 1234' and others in full phone number format '(555) 123-4567' or 123-4567. Format based on length.
I could do this as text fields, but I thought using conditional formatting would be a whole lot cooler and be a great learning experience . Now that I can't figure it out, it's become a challenge. I'd prefer not to use VBA for this solution.
Any ideas. Thanks,
Excel VBA-Number Format If...
I have 4 nos. in validations (10,12, 15.2, 16) for a cell in excel sheet. I want to format the cell such that 15.2 if selected will display 15.2 but if any other is selected will not display decimal (say, should not display 10.0 if 10 is selected).
I put code in VBA as:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = 15.2 Then
Range("A1").Value = 15.2
Else: Range("A1").Value = Range("A1").Value
This works fine, but...
the undo button is inactive, that means if want to undo the input, I cannot.
For all the things in the 'Worksheet_SelectionChange' this happens (the Undo button cannot be clicked)
Please explain why and provide a solution.
Number Format Problem?
Howdy. Let me try to explain what I'm doing here.
I have 2 spreadsheets I'm working with. One has percentages that change on a weekly basis. I'm trying to copy those over to the other spreadsheet via a macro. In order to copy the correct percentage, I do a comparison by ZIP so the correct percent will go to the correct row/column in the second spreadsheet.
OK, when I run this not all of the percentages are getting updated as they should. I've put a breakpoint at the proper place in the macro, and I have added watches to see what is going on. One watch, ZIP, I put on the destination spreadsheet. The other watch, ZIP2, I put on the source spreadsheet. When I'm watching these values change I notice that sometimes the ZIP column will have the correct ZIP, but it will have quotes around it such as "60101", while the other one ZIP2, will contain the number without quotes such as 60101. Therefore, they are not seen as being equal and the new percentage doesn't get copied over.
(sigh) I hope I'm explaining this clearly. Does anyone know why this gets formatted in this way? I've tried formatting columns in both spreadsheets to be General, Text, and Numbers with no decimal places or comma dividers, but it's the same story no matter what.
Any help will be greatly appreciated.
Format Number To String
I've a number like the number below
I format the number as double, VB trim the number
Dim test as double
test = 3.24234234234342E+83
For so far no problem,
But now i convert test to a String
test2 = Str(test)
msgbox test2 shows 3.24234234234342E+83 instead of the long number...
is it possible to show the long number??
Sql-string -- Format Number
sql = "Select name,age,formatnumber(sum,2) from tbl1"
What do I wrong ?
I fill a flexgrid with the recordset, and the column "sum" should
display example 6,50
Without format is it shows 6,5000000001
Format Unique Number
Private Sub form_load()
Select Case Len(CStr(Adodc1.Recordset.RecordCount))
Case 1: Text1.Text = FormatDateTime(Date) + "00" & Format(Adodc1.Recordset.RecordCount)
Case 2: Text1.Text = FormatDateTime(Date) + "0" & Format(Adodc1.Recordset.RecordCount)
Case 3: Text1.Text = FormatDateTime(Date) + Format(Adodc1.Recordset.RecordCount)
I hv the above code to act as the unique number as an invoice number that has the format like 31-Dec-2005001, 31-Dec-2005002, 01-Jan-2005003Ö. etc where 01-Jan-2005 is the current date and 002 indicates the number of record. Wht modification can I make in order to make the number restart at 001 when the next day? E.g. 01-Jan-2005001 instead of 01-Jan-2005003?
I have the following pseudocode idea but I donít know how to accomplish it by coding. Pls provide, TQ.
1. Get the latest record from the database and extract the ID. Split
them into two parts : The date and the counter. Put them into two
2. Compare the current date with the date you have extracted just
now. If they are the same, it means that the latest transaction is
from today. If it isn't, you are making the first transaction for
today. If that's the case, concatenate the value 001 to your current
date and store it as the ID
3. If it is the same, just increment the last counter by 1 and do the
same thing. Concatenate the incremented counter by current date and
store it as the ID
My db specifications are as follows:
field name: job_id
field type: Text
field size: 50
Number Format In Textbox ...
I would like to view numbers in the following format in a Textbox:
Just a comma (a separator) after 3 digits from right in a Textbox. How can I do that?
Number Format For Textbox
how will i set the code for the textbox which will not accept a user input if it enters an alphabet.... and t will prompt you that u did not input a proper number format.
thanks.. i hope you code give a sample code.....
Added [RESOLVED] to thread title and green "resolved" checkmark - Hack
Format Number As Currency
Alright now; this problem has been seriously bothering me.
I'm attempting to make something that displays an amount of money for every hour/minute/second worked.
It works, but the number I get has an obscene amount of numbers after the decimal point.
How do I format the number like a currencey?(USD)
so, that it's like #####.## with only two numbers after the decimal point?
Thanks in advance.
Format Number To A Price
How do I format a number such as '3' or '3.0' or '3.002', all to '3.00'? Basically, I want to make all numbers into a 'price' format, meaning :
I tried several methods, but they didn't work.
Format Number Problem
How can I convert '1' to this format: '1.00 + 00' without using
"MaskEditBox" control!!!(only function)
Textbox - Number Format
wat the format for the text box... to be start with 00001, n continue with 00002...
how come i cant get the 0 at the front...
x = format(x,"00000")
is tat work??
Format A Number In A String??
I am using the following code to label x values on a graph which i have draw in a picture box. I want the lables to appear as:
"0.7", "1.0", "1.2" etc
however they appear as ".7" and "1" instead. How can i change this??? (Note picboxXlbl is directly under picGraph, with the same width!)
Private Sub ScaleGraph()
Dim i As Integer, lbl As String, labelX() As String
Dim lblWid, lblHght, tickFactor As Single
Dim xMin, xMax, yMin, yMax, xloc As Single
xMin = 0.2
xMax = 1.2
yMin = 0.2
yMax = 1.2
picGraph.Scale (xMin, yMax)-(xMax, yMin)
picboxXlbl.Scale (xMin, 1)-(xMax, 0)
numXlbls = Int((xMax - xMin) / 0.1)
ReDim labelX(1 To numXlbls)
'Draw tick marks and label them
For i = 2 To numXlbls
xloc = xMin + (i - 1) * 0.1
labelX(i) = Str(Format(xloc, "0.0"))
lblWid = picGraph.TextWidth(labelX(i))
picboxXlbl.CurrentX = xloc - lblWid / 2
picboxXlbl.CurrentY = 0.9
Scientific Number Format
i have the follwing subroutine which formats a number into a scientific format:
Public Function Sci(number, DP) As String
Sci = Left$(Trim(Str(number)), 1) & "." & Mid$(Replace(Trim(Str(number)), ".", ""), 2, DP) & " E" & Str(InStr(1, Trim(Str(number)), ".") - 2)
However the ouput is 8.6100 E 5
i would like it to appear as 8.6100E+05
how do i do this, and ideas??? Also i thought that i could set the number format property of a text box to how i desire, as i tried to set the scientific number format here, but this did not appear to work!
Please help !!!
Format Number Output
looking to output a result that is right justified that will allow for 6 places.
the output number is 234
so i want to get this output
i tired using
however, it comes out with
how would you get rid of the zeros.
thanx very much for your help!