by Robert Payne (2 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Wed 20th September 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code changes a number into Engineering format, example 1000 goes to 1k
OUT = NUM
If OUT = 0 Then
ENG = ""
ElseIf OUT >= 1 Then
While OUT >= 1000
OUT = OUT / 1000
DoEvents
ENGPART = ENGPART + 1
Wend
Select Case ENGPART
Case 1: ENG = "k" '1000
Case 2: ENG = "M"
Case 3: ENG = "G"
Case 4: ENG = "T"
Case Else: ENG = NUM: OUT = ""
End Select
Else
While OUT < 1
OUT = OUT * 1000
DoEvents
ENGPART = ENGPART + 1
Wend
Select Case ENGPART
Case 1: ENG = "m" '0.001
Case 2: ENG = "u"
Case 3: ENG = "n"
Case 4: ENG = "p"
Case 4: ENG = "f"
Case 4: ENG = "a"
Case Else: ENG = NUM: OUT = ""
End Select
End If
NUM2ENG = OUT & ENG
End Function
No comments have been posted about This code changes a number into Engineering format, example 1000 goes to 1k. Why not be the first to post a comment about This code changes a number into Engineering format, example 1000 goes to 1k.