05-21-2025, 03:34 PM
Hi Phil
Like you, I find I use Subs a lot more than Functions but with my coding I often find I'm dealing with Scientific Notation and a Function here has really sped up things. I'm sure there is likely a better Function routine for handling Scientific Notation but here's an out line of my favorite Function.
And if this looks familiar to either Steve or Mark, or another on this forum, then yes, I likely did find it here and thank you for same.
Like you, I find I use Subs a lot more than Functions but with my coding I often find I'm dealing with Scientific Notation and a Function here has really sped up things. I'm sure there is likely a better Function routine for handling Scientific Notation but here's an out line of my favorite Function.
Code: (Select All)
Dim Shared Number, x, y
'In the main modula will be a calculation which generates a Scientifically Notated value
Number = 115 / 123456
Print Number
x = 115
y = 123456
Number = SNrid
Print Number
Function SNrid
ScNote$ = Str$(x / y)
If InStr(1, ScNote$, "E") Or InStr(1, ScNote$, "D") Then 'This power requires moving the decimal 4 places to the left. E = Single Precision = 7 total digits
SNA = x / y
a = SNA * 10000000
b = a \ 1
C = a - b
If C >= .5 Then
b = b + 1
SNB = b * .0000001
End If
If C < .5 Then
SNB = b * .0000001
End If
SNrid = SNB
Exit Function
End If
SNrid = x / y
End Function
And if this looks familiar to either Steve or Mark, or another on this forum, then yes, I likely did find it here and thank you for same.