This topic is locked

Displaying numeric values in scientific notation

3/16/2019 10:48:48 AM
ASPRunnerPro Tips and tricks
admin

Here is how you can display numbers in scientific notation in your ASPRunnerPro application.

  1. In source subfolder under you project folder create a file named scientific.asp and paste the following code there:

<%
Function NSN(Number, Accuracy)

Exponent = 0

If Number > 0 Then

Sign = 1

ElseIf Number < 0 Then

Sign = -1

Else

NSN = 0

Exit Function

End If

Number = Number * Sign

If Number >= 10 Then

While Number >= 10

Number = Number / 10

Exponent = Exponent + 1

Wend

ElseIf Number < 1 Then

While Number < 1

Number = Number * 10

Exponent = Exponent - 1

Wend

End If

Number = Round(Number, Accuracy)

If Number = "10" Then

Number = 1

Exponent = Exponent + 1

End If

Number = Number * Sign

If Exponent = 0 Then

NSN = Number

Else

NSN = Number & "E" & Exponent

End If

End Function
%>


2. In AfterAppInit event add the following code:

asp_include "scientific.asp",false


This will make functions defined in scientific.asp file available in ASPRunnerPro project.
3. Set 'View as' type of this field to Custom and paste the following code there:

strValue = NSN(strValue, 4)