Advertisement
veronikaaa86

Num As Text - VBA

Dec 23rd, 2021
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Sub LiveDemo()
  2. Dim result As String
  3. result = NumAsText(324)
  4.  
  5. Debug.Print result
  6.  
  7. End Sub
  8.  
  9. Function NumAsText(num As Integer)
  10. If num = 1 Then
  11. NumAsText = "one"
  12. ElseIf num = 2 Then
  13. NumAsText = "two"
  14. ElseIf num = 3 Then
  15. NumAsText = "three"
  16. ElseIf num = 4 Then
  17. NumAsText = "four"
  18. ElseIf num = 5 Then
  19. NumAsText = "five"
  20. ElseIf num = 6 Then
  21. NumAsText = "six"
  22. ElseIf num = 7 Then
  23. NumAsText = "seven"
  24. ElseIf num = 8 Then
  25. NumAsText = "eight"
  26. ElseIf num = 9 Then
  27. NumAsText = "nine"
  28. Else
  29. NumAsText = "not a digit"
  30. End If
  31. End Function
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement