My program asks for the number of times a baseball player has gone to bat and the number of times he has hit.
when it prints the average, how can I remove the 0 before the decimal?
Also, how can I guarantee that the decimal will be three places long?
Thanks,
Levells
With the following code, when i enter 500,267 it results in .534
but when I enter 500,250 it results in 0.5
Code:
Private Sub cmdCompute_Click()
    Dim whole As String, bat, hit, avg As Single
    whole = InputBox("Enter the number of times at bat and the number of hits, separated by a comma.", "Batting Average")
    picbox.Cls
    bat = Val(Left(whole, InStr(whole, ",") - 1))
    hit = Val(Right(whole, InStr(whole, ",") - 1))
    avg = FormatNumber(hit / bat, 3)
    picbox.Print "Being at bat"; bat; "times and hitting"; hit; "times gives a batting average of "; Right(avg, Len(avg))
End Sub