Solved

# Converting Fractions to Decimals

Posted on 2003-11-28

Using AC2002.

I am using the following code to convert fractions to decimals. However, it won't convert the number if it is a whole number only. Need help in modification.

Private Sub Command1_Click()

Dim x As Integer

Dim y As Integer

Dim z As String

Dim a1 As Integer

Dim a2 As Integer

Dim MyNumber As String

DoCmd.GoToControl "Text1"

x = InStr(1, Text1.Text, " ")

y = InStr(x, Text1.Text, "/")

z = Right$(Text1.Text, Len(Text1.Text) - x)

y = InStr(1, z, "/")

a1 = Val(Left$(z, y - 1))

a2 = Val(Right$(z, Len(z) - y))

MyNumber = Val(Left$(Text1.Text, x - 1)) + a1 / a2

Text1.Text = MyNumber

End Sub