Firstly, to "clean" a string the starts with a numeric character, you use the "Val(" function. I think you are also expecting the "entry" parameter to be changed by the CleanCode function, however you must explicitly return the value.
Function CleanCode(entry) As Integer
entry = Val(entry)
If entry Like "[4]" Then
entry = 4
Else
entry = -1
End If
CleanCode = entry
End Function
We can call this function from another function to see how it operates:
Sub CallCC()
Dim entry As Variant
entry = "9th"
Dim Result As Integer
Result = CleanCode(entry)
MsgBox "Result = " & Result
'Result is -1
entry = "4th grade"
Result = CleanCode(entry)
MsgBox "Result = " & Result
' Result = 4
End Sub