I'm having some trouble with passing a value from a Function to a Sub.
Below is the code I wrote.
I'm trying to convert a number (integer) to a letter (string) to use for something else later on.
I put in some MsgBox's to see what's happening, trying to understand the problem....
Code: Select all
Sub TESTMacro()
Dim sNumToLetter As String
sNumToLetter = NumToLetter(2)
MsgBox "NumToLetter=" & sNumToLetter
End Sub
Function NumToLetter (iNum As Integer)
Dim oLet As String
Select Case iNum
Case 1: oLet = "A"
Case 2: oLet = "B"
Case 3: oLet = "C"
Case 4: oLet = "D"
Case 5: oLet = "E"
Case 6: oLet = "F"
Case 7: oLet = "G"
Case 8: oLet = "H"
Case 9: oLet = "I"
Case 10: oLet = "J"
Case 11: oLet = "K"
Case 12: oLet = "L"
Case 13: oLet = "M"
Case 14: oLet = "N"
Case 15: oLet = "O"
Case 16: oLet = "P"
Case 17: oLet = "Q"
Case 18: oLet = "R"
Case 19: oLet = "S"
Case 20: oLet = "T"
Case 21: oLet = "U"
Case 22: oLet = "V"
Case 23: oLet = "W"
Case 24: oLet = "X"
Case 25: oLet = "Y"
Case 26: oLet = "Z"
End Select
MsgBox "iNum=" & iNum & " ; oLet=" & oLet
End Function
iNum (input) value is 2, oLet (output) value is B according to the MsgBox within the Function.
However the value for sNumToLetter is empty according to the MsgBox within the Sub.
What am I missing here?