Inch to feet fraction converter
ITemp = 0 ' \ The number we've been bulding must be the numerator of fraction ElseIf vChar = " /" Then ITemp = 0 End If ' \ As we read number from left to right, we multiply value of previous ' \ number (if any) by 10 and add this number If iTemp = 0 ThenĮnd If ' \ The number we've been buiding must be feet ElseIf vChar = " '" Or vChar = " f" Then ' \ If character is a number, then we combine it with numbers before it ' \ to get a number that we can assign to feet, inches, numerator or denominator If IsNumeric(vChar) Then ' \ If this is a number and the last character was a space then ' \ chances are, the number in iTemp is inches and we need to ' \ start over building the numerator of fractional inches If bLastCharWasSpace = True And iIn = 0 Then ' \ If input string is numeric, then we don't want to convert it If IsNumeric(vVal) ThenĮxit Function End If ' \ Now we step through each character in input string from left to rightīLastCharWasSpace = False For i = 1 To Len(vVal) VVal = Text_string_containing_values_for_Feet_Inches ' \ These values are used to examine the input string, one character at a time Dim vVal As String ' \ shorter name for input string Dim i As Integer ' \ counter to step through each character in input string Dim vChar As Variant ' \ temporary storage of each input string character ' \ These variables hold the values we discover for feet, inches and the ' \ numerator and denominator of the fractional inches Dim iFt As Integer ' \ used to store number of feet Dim iIn As Integer ' \ number of inches Dim iNumerator As Integer ' \ numerator of fractional inches Dim iDenominator As Integer ' \ denominator of fractional inches ' \ In the process of discovering values for feet and inches, these variable ' \ are used to accumulate and hold numeric values Dim iTemp As Integer ' \ Used to build a number as each digit is read ' \ We want to ignore spaces, except for the very important space between ' \ the number of inches and the numerator of the fractional inches ' \ This variable is true if the last character processed was a space Dim bLastCharWasSpace As Boolean ' \ First we assign input string to variable with shorter name Function CInches(Text_string_containing_values_for_Feet_Inches)
#Inch to feet fraction converter code
Copy Code Option Explicit ' \ This function converts a string like 5'-6 1/4" to a decimal number ' \ of inches that can be used in calculation.