L
Lumpy
I use some specialized CAD software to design timber structures. It supports
some export to Access and has some limited Access database functionality that
the developer has provided. In German.
The module below converts a integer mm value that gets exported from the CAD
software into a table. It converts it into what I would call "architectural"
format. I need to make a very similar function that converts to what I would
call "fractional" format. Where:
28.25 = Decimal format
2'-4 1/4" = Architectural format
28 1/4" = Fractional format
Seems like it should be pretty easy but there is some rounding involved and
I don't understand the VBA code too well. Add in german variable and I'm
lost.
If someone just commented this code, I could probably hack together what I
need.
Thanks,
Kurt
Option Compare Database
Function MMToInch$(MMm)
Aantalmm = MMm + 1 / 16
AantalInch = Fix(Aantalmm / 25.4)
AantalFeet = Fix(AantalInch / 12)
AantalRestInch = AantalInch - AantalFeet * 12
FractieInch = Aantalmm / 25.4 - AantalInch
' test = FractieInch * 32
TelLer = Fix(FractieInch * 16 + 0.5)
If TelLer = 16 Then
TelLer = 0
AantalRestInch = AantalRestInch + 1
If AantalRestInch = 12 Then
AantalFeet = AantalFeet + 1
AantalRestInch = 0
End If
End If
Noemer = 16
Gedaan = False
Do
If TelLer = Fix(TelLer / 2) * 2 Then
TelLer = TelLer / 2
Noemer = Noemer / 2
Else
Gedaan = True
End If
Loop Until Gedaan Or TelLer = 0
If AantalFeet > 0 Then
Inch$ = Mid$(Str$(AantalFeet), 2) + "' "
Else
Inch$ = ""
End If
If AantalRestInch > 0 Then
Inch$ = Inch$ + Mid$(Str$(AantalRestInch), 2)
End If
If TelLer > 0 Then
Inch$ = Inch$ + " " + Mid$(Str$(TelLer), 2) + "/" +
Mid$(Str$(Noemer), 2)
End If
If TelLer > 0 Or AantalRestInch > 0 Then
Inch$ = Inch$ + Chr$(34)
End If
MMToInch$ = Inch$
End Function
some export to Access and has some limited Access database functionality that
the developer has provided. In German.
The module below converts a integer mm value that gets exported from the CAD
software into a table. It converts it into what I would call "architectural"
format. I need to make a very similar function that converts to what I would
call "fractional" format. Where:
28.25 = Decimal format
2'-4 1/4" = Architectural format
28 1/4" = Fractional format
Seems like it should be pretty easy but there is some rounding involved and
I don't understand the VBA code too well. Add in german variable and I'm
lost.
If someone just commented this code, I could probably hack together what I
need.
Thanks,
Kurt
Option Compare Database
Function MMToInch$(MMm)
Aantalmm = MMm + 1 / 16
AantalInch = Fix(Aantalmm / 25.4)
AantalFeet = Fix(AantalInch / 12)
AantalRestInch = AantalInch - AantalFeet * 12
FractieInch = Aantalmm / 25.4 - AantalInch
' test = FractieInch * 32
TelLer = Fix(FractieInch * 16 + 0.5)
If TelLer = 16 Then
TelLer = 0
AantalRestInch = AantalRestInch + 1
If AantalRestInch = 12 Then
AantalFeet = AantalFeet + 1
AantalRestInch = 0
End If
End If
Noemer = 16
Gedaan = False
Do
If TelLer = Fix(TelLer / 2) * 2 Then
TelLer = TelLer / 2
Noemer = Noemer / 2
Else
Gedaan = True
End If
Loop Until Gedaan Or TelLer = 0
If AantalFeet > 0 Then
Inch$ = Mid$(Str$(AantalFeet), 2) + "' "
Else
Inch$ = ""
End If
If AantalRestInch > 0 Then
Inch$ = Inch$ + Mid$(Str$(AantalRestInch), 2)
End If
If TelLer > 0 Then
Inch$ = Inch$ + " " + Mid$(Str$(TelLer), 2) + "/" +
Mid$(Str$(Noemer), 2)
End If
If TelLer > 0 Or AantalRestInch > 0 Then
Inch$ = Inch$ + Chr$(34)
End If
MMToInch$ = Inch$
End Function