I am doing a Celsius to Fahrenheit conversion,
the problem is that the converted figure must include only 2 characters beyond the decimal point (if any) and nothing if there are no decimals.
With the code below, it is doable, except that when the answer is a whole number (No decimals), then it still displays the decimal point.
How can I suppress the decimal point in this case?
Examples:-
Format$(35.1234, "####.##") ' gives "35.12" - fine
Format$(35.1, "####.##") ' gives "35.1" - fine
Format$(35, "####.##") ' gives "35." - Not fine, must give "35" (with no decimal point)
the problem is that the converted figure must include only 2 characters beyond the decimal point (if any) and nothing if there are no decimals.
With the code below, it is doable, except that when the answer is a whole number (No decimals), then it still displays the decimal point.
How can I suppress the decimal point in this case?
Examples:-
Format$(35.1234, "####.##") ' gives "35.12" - fine
Format$(35.1, "####.##") ' gives "35.1" - fine
Format$(35, "####.##") ' gives "35." - Not fine, must give "35" (with no decimal point)
Code:
Case %wm_command Select Case As Long Cb.Ctl Case %IDC_BUTTON3 ' Convert from C to F Control Get Text Cb.Hndl, %IDC_TEXTBOX1 To sTxt$ sFmTxt$ = Str$((9/5)*(Val(sTxt$))+32) Control Set Text Cb.Hndl, %IDC_TEXTBOX2, Format$(Val(sFmTxt$), "####.##") Case %IDC_BUTTON4 ' Convert from F to C Control Get Text Cb.Hndl, %IDC_TEXTBOX2 To sTxt$ sFmTxt$ = Str$((5/9)*(Val(sTxt$)-32)) Control Set Text Cb.Hndl, %IDC_TEXTBOX1, Format$(Val(sFmTxt$), "####.##") End Select ' Cb.Ctl
Comment