Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
BWMcDowell
in reply to: Anonymous

I wrote this bit of code to do just that in a string

it rounds up to the nearest 16th

 

 

Sub Main()
'CALCULATE RUNG TOTAL LENGTH
RUNGTOTLG = ""
FEET = Floor(RUNGLG/12)
INCH = Floor(RUNGLG - (FEET * 12))
FRAC = Ceil((RUNGLG - (FEET * 12) - INCH) *  16)
RUNGTOTLG = FEET & "'- " & INCH & TOFRACTION(FRAC) & Chr(34)
End Sub

Function TOFRACTION(NEUMERATOR As Integer ) As String
Select Case NEUMERATOR
Case 0
Return ""
Case 1
Return " 1/16"
Case 2
Return " 1/8"
Case 3
Return " 3/16"
Case 4
Return " 1/4"
Case 5
Return " 5/16"
Case 6
Return " 3/8"
Case 7
Return " 7/16"
Case 8 
Return " 1/2"
Case 9
Return " 9/16"
Case 10
Return " 5/8"
Case 11
Return " 11/16"
Case 12
Return " 3/4"
Case 13
Return " 13/16"
Case 14
Return " 7/8"
Case 15
Return " 15/16"
End Select
End Function

 

hope this helps