-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtwoDigitNumberToText.bas
50 lines (43 loc) · 1.87 KB
/
twoDigitNumberToText.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''''''''''''''''''''''''''''''''''''''''''''''
' Two Digit number To Text '
'''''''''''''''''''''''''''''''''''''''''''''''
'recieves any two digit number as twoDigits (ex. "12") as string
'outputs a string as text (ex. "Twelve")
' *** Requires Function "oneDigitNumberToText" ***
Function twoDigitNumberToText(twoDigits As String) as String
'dimension variables
Dim result As String: result = ""
' If value between 10-19
If val(Left(twoDigits, 1)) = 1 Then
Select Case val(twoDigits)
Case 10: result = "Ten"
Case 11: result = "Eleven"
Case 12: result = "Twelve"
Case 13: result = "Thirteen"
Case 14: result = "Fourteen"
Case 15: result = "Fifteen"
Case 16: result = "Sixteen"
Case 17: result = "Seventeen"
Case 18: result = "Eighteen"
Case 19: result = "Nineteen"
Case Else
End Select
' If value between 20-99
Else
Select Case val(Left(twoDigits, 1))
Case 2: result = "Twenty "
Case 3: result = "Thirty "
Case 4: result = "Forty "
Case 5: result = "Fifty "
Case 6: result = "Sixty "
Case 7: result = "Seventy "
Case 8: result = "Eighty "
Case 9: result = "Ninety "
Case Else
End Select
' Retrieve ones place
result = result & common.oneDigitNumberToText(Right(twoDigits, 1))
End If
'return
twoDigitNumberToText = result
End Function