Jump to content

Unit Accuracy Question


Recommended Posts

Posted

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

Posted

without looking myself have a look at the FORMAT command. You should be able to give it a mask to copy. (I think)

Posted

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]

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...