Ft. Inches Fraction Decimal
0ft 1 inch ---> 1/16 ??? ---> 0.063 (rounded up to 3 decimal places)
0ft. 2 inch ---> ??? ----> ?????
0ft. 3 inch ---> ??? ----> ?????
0ft. 4 inch ---> ??? ----> ?????
0ft. 5 inch ---> ??? ----> ?????
0ft. 6 inch ---> ??? ----> ?????
0ft. 7 inch ---> ??? ----> ?????
0ft. 8 inch ---> ??? ----> ?????
0ft. 9 inch ---> ??? ----> ?????
0ft. 10 inch ---> ??? ----> ?????
0ft. 11 inch ---> ??? ----> ?????
0ft. 12 inch ---> ??? ----> ?????
1ft 1 inch ---> ??? ----> ??? (rounded up to 3 decimal places)
1ft. 2 inch ---> ??? ----> ?????
1ft. 3 inch ---> ??? ----> ?????
1ft. 4 inch ---> ??? ----> ?????
1ft. 5 inch ---> ??? ----> ?????
1ft. 6 inch ---> ??? ----> ?????
1ft. 7 inch ---> ??? ----> ?????
1ft. 8 inch ---> ??? ----> ?????
1ft. 9 inch ---> ??? ----> ?????
1ft. 10 inch ---> ??? ----> ?????
1ft. 11 inch ---> ??? ----> ?????
2ft. 0 inch ---> ??? ----> ?????
2ft. 1 inch ---> ??? ----> ?????
2ft. 2 inch ---> ??? ----> ?????
...and so on and so forth
up to
30ft 0 inch ---> ??? ----> ???? (rounded up to 3 decimal places)
Public Function FeetFraction(ByVal dblMeasure As Double) As String
Dim dblFraction As Double
Dim strFraction As String
dblFraction = TimeValue(CDate(dblMeasure))
Select Case dblFraction
Case Is < 1 / 12
strFraction = ""
Case Is < 2 / 12
strFraction = "1/12"
Case Is < 3 / 12
strFraction = "1/6"
Case Is < 4 / 12
strFraction = "1/4"
Case Is < 5 / 12
strFraction = "1/3"
Case Is < 6 / 12
strFraction = "5/12"
Case Is < 7 / 12
strFraction = "1/2"
Case Is < 8 / 12
strFraction = "7/12"
Case Is < 9 / 12
strFraction = "2/3"
Case Is < 10 / 12
strFraction = "3/4"
Case Is < 11 / 12
strFraction = "5/6"
Case Is < 12 / 12
strFraction = "11/12"
End Select
FeetFraction = strFraction
End Function
Public Function inchasfraction(inch As Integer) As String
If inch = 1 Then
inchasfraction = "1/16"
ElseIf inch = 2 Then
inchasfraction = "3/16"
ElseIf inch = 3 Then
inchasfraction = "1/4"
ElseIf inch = 4 Then
inchasfraction = "5/16"
ElseIf inch = 5 Then
inchasfraction = "7/16"
ElseIf inch = 6 Then
inchasfraction = "1/2"
ElseIf inch = 7 Then
inchasfraction = "9/16"
ElseIf inch = 8 Then
inchasfraction = "11/16"
ElseIf inch = 9 Then
inchasfraction = "3/4"
ElseIf inch = 10 Then
inchasfraction = "13/16"
ElseIf inch = 11 Then
inchasfraction = "15/16"
Else
inchasfraction = ""
End If
End Function
Feet-To-Fractions-211.mdb
Public Function FeetFraction(ByVal dblMeasure As Double) As String
On Error Resume Next
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim intInch As Integer
Dim dblFraction As Double
Dim strFraction As String
' Fill tblFeet.Decimal with data first
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblFeet")
With rst
For intInch = 1 To 30 * 12
Debug.Print intInch / 12
.AddNew
!DECIMAL.Value = intInch / 12
.Update
Next
.Close
End With
'Assume failure
err.Clear
Dim sSQL As String
sSQL = "SELECT tblFeet.Decimal, Int([Decimal]) & "ft. " & Format(TimeValue(CDate([Decimal]))/2,"h") & "in." AS FeetInch, " & _
"Int([Decimal]) AS Feet, FeetFraction([Decimal]) AS Fraction, " & _
"IIf(Int([Decimal])=0,"",Int([Decimal])) & IIf(Int([Decimal])=[Decimal] Or [Decimal]<1,"","-") & FeetFraction([Decimal]) AS FeetAndInch, " & _
"Format([Decimal],"0.000") AS Decimal3Text INTO tblFeetInch " & _
"FROM tblFeet " & _
"ORDER BY tblFeet.Decimal "
Set rst = CurrentDb.OpenRecordset(sSQL)
If err.Number > 0 Then
MsgBox "Failed to read the table " & err.Description, vbCritical
Else
'ok, no errors so far, lets return true to indicate no failure
' Now fill in data for fraction
dblFraction = TimeValue(CDate(dblMeasure))
Select Case dblFraction
Case Is < 1 / 12
strFraction = ""
Case Is < 2 / 12
strFraction = "1/12"
Case Is < 3 / 12
strFraction = "1/6"
Case Is < 4 / 12
strFraction = "1/4"
Case Is < 5 / 12
strFraction = "1/3"
Case Is < 6 / 12
strFraction = "5/12"
Case Is < 7 / 12
strFraction = "1/2"
Case Is < 8 / 12
strFraction = "7/12"
Case Is < 9 / 12
strFraction = "2/3"
Case Is < 10 / 12
strFraction = "3/4"
Case Is < 11 / 12
strFraction = "5/6"
Case Is < 12 / 12
strFraction = "11/12"
End Select
FeetFraction = strFraction
End If
End If
Set rst = Nothing
Set dbs = Nothing
Exit Function
End Function
Public Function ConvertFtDec(ByVal dblMeasure As Double) As String
On Error Resume Next
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim intInch As Integer
Dim dblFraction As Double
Dim strFraction As String
' Fill tblFeet.Decimal with data first
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblFeet")
With rst
For intInch = 1 To 30 * 12
Debug.Print intInch / 12
.AddNew
!DECIMAL.Value = intInch / 12
.Update
Next
.Close
End With
'Assume failure
Err.Clear
Dim sSQL As String
sSQL = "SELECT tblFeet.Decimal, Int([Decimal]) & 'ft. ' & Format(TimeValue(CDate([Decimal]))/2,'h') & 'in.' AS FeetInch, " & _
"Int([Decimal]) AS Feet, FeetFraction([Decimal]) AS Fraction, " & _
"IIf(Int([Decimal])=0,'',Int([Decimal])) & IIf(Int([Decimal])=[Decimal] Or [Decimal]<1,'','-') & FeetFraction([Decimal]) AS FeetAndInch, " & _
"Format([Decimal],'0.000') AS Decimal3Text INTO tblFeetInch " & _
"FROM tblFeet " & _
"ORDER BY tblFeet.Decimal "
Set rst = CurrentDb.OpenRecordset(sSQL)
If Err.Number > 0 Then
MsgBox "Failed to read the table " & Err.Description, vbCritical
Else
'ok, no errors so far, lets return true to indicate no failure
' Now fill in data for fraction
dblFraction = TimeValue(CDate(dblMeasure))
Select Case dblFraction
Case Is < 1 / 12
strFraction = ""
Case Is < 2 / 12
strFraction = "1/12"
Case Is < 3 / 12
strFraction = "1/6"
Case Is < 4 / 12
strFraction = "1/4"
Case Is < 5 / 12
strFraction = "1/3"
Case Is < 6 / 12
strFraction = "5/12"
Case Is < 7 / 12
strFraction = "1/2"
Case Is < 8 / 12
strFraction = "7/12"
Case Is < 9 / 12
strFraction = "2/3"
Case Is < 10 / 12
strFraction = "3/4"
Case Is < 11 / 12
strFraction = "5/6"
Case Is < 12 / 12
strFraction = "11/12"
End Select
FeetFraction = strFraction
End If
Set rst = Nothing
Set dbs = Nothing
Exit Function
End Function
deleted by modus_operandi
Undeleted and non-relavent content removed by modguy
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
9 Experts available now in Live!