Public Function feet_inch(dist as double) as string
Dim feet As Integer
Dim inch As Double
Dim s As String
dist=dist/dpi
feet=Floor(dist/12)
If feet>0 Then s=Str(feet)+"'"
dist=dist-(feet*12)
inch=Floor(dist)
If inch>0 Then
s=s+Str(inch)
dist=dist-inch
End If
If dist>0 Then // fraction
If dist>0 And dist<=0.25 Then
s=s+&Ubc
Elseif dist>0.25 And dist<=0.50 Then
s=s+&Ubd // 1/2
Elseif dist>0.50 Then
s=s+&ube
End If
End If
If inch>0 Or dist>0 Then s=s+ChrB(34)
s=s.ConvertEncoding(encodings.UTF8)
Return s
End Function
am trying to convert a value in INCHES to FEET and Inches to the nearest 1/4"
but when I use Drawstring on the result and “fractions” come out as black diamonds
[quote=427055:@Dave S]@anon20074439 Change ChrB to Chr ?
that was for the quote to indicate inches… its the &UBE etc that isn’t working[/quote]
Using ChrB breaks the encoding of the string and sets it to Nil, you should be using Chr instead as I mentioned earlier.
It seems that you can’t ConvertEncoding from a Nil encoding to something else which is where the problem lies and makes sense, not that encoding done inside the function isn’t returned. DefineEncoding will force the encoding, if you use DefineEncoding in your function, it will work and you wont need to define the encoding again outside the function or you could use Chr and stick with ConvertEncoding.