Below is an example function with a switch statement, however I'm having a hard time understanding how a function can equal an argument provided?
Function getnumber(value, method) As String
Dim i, j As Integer
Dim rtn As String
j = 0
Select Case method
Case 0:
getnumber = value
Case 1:
rtn = ""
For i = 1 To Len(value)
If IsNumeric(Mid(value, i, 1)) Then
j = j + 1
rtn = rtn & Mid(value, i, 1)
Else
If j > 3 Then Exit For
j = 0
rtn = ""
End If
Next
If rtn = "" Then getnumber = "" Else getnumber = rtn
Case Else:
MsgBox ("Invalid method in getnumber")
End Select
End Function
"getnumber = value" is really confusing me. Where getnumber is the function and value is an argument of the getnumber function
Any ideas?
getnumber = valueis the return value - the calling code will receivevalueif it callsgetnumber(value, method).Dim i, j As Integershould beDim i As Integer, j As Integer, value and method should be dimensioned too (I thinkAs VariantorAs StringandAs Integer)