skipsophrenic Posted September 18, 2008 Posted September 18, 2008 In VBA i'v been doing myself a little program to help me with my mm to inches and vica versa conversions, however when i do 1 mm to 1 inch when i run the program it's coming out with a large string of numbers, what do i need to do to get it to show accuracy within 2 decimal places? Here's the code for the button at the moment. Private Sub Cmd_run_mm_Click() Me.Lbl_mm_to_inch_answer.Visible = True ' makes the label visible Me.Lbl_mm_to_inch_answer.Caption = Me.Value_box.Value / 2.54 ' Divides the value in the text box by 2.54 End Sub Quote
dbroada Posted September 18, 2008 Posted September 18, 2008 without looking myself have a look at the FORMAT command. You should be able to give it a mask to copy. (I think) Quote
skipsophrenic Posted September 18, 2008 Author Posted September 18, 2008 Using the help function to find the format option i've added an extra string to the code, but I'm still getting a P.E.B.K.A.C error! Private Sub Cmd_run_mm_Click() Me.Lbl_mm_to_inch_answer.Visible = True Me.Lbl_mm_to_inch_answer.Caption = Me.Value_box.Value / 2.54 ' Divides the value in the text box by 2.54 Lbl_mm_to_inch_answer , MyStr = Format(5459.4, "##,##0.00") End Sub[/Code] Quote
dbroada Posted September 18, 2008 Posted September 18, 2008 try this... Me.lbl_mm_to_inch_answer.Caption = Format(Me.Value_box.Value / 2.54, "####0.00") ' Divides the value in the text box by 2.54 Quote
skipsophrenic Posted September 18, 2008 Author Posted September 18, 2008 Cheers m8, that fixed it Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.