Parameter with type "Variant" equals anything?
I usually have all variables typed - seldom use variant
Hi,
I almost always put in the type of a variable. I seldom use variant.
In this case, by not specifying txt as string, it gave me unexpected results.
It seems txt is equal to anything.
My answer is to put "txt as string" as I should have.
And again, Regards, Dave
Uses "Console"
Sub TBMain()
ckIterate1("One")
PrintL
ckIterate2("Two")
WaitKey
End Sub
Sub CkIterate1(txt) ' note, no type (or variant)
If txt = "Header" Then
PrintL txt & " equals 'Header'"
End If
If txt = "Footer" Then
PrintL txt & " equals 'Footer'"
End If
PrintL "txt: <" & txt & ">"
End Sub
Sub CkIterate2(txt As String) ' note, txt as string
If txt = "Header" Then
PrintL txt & " equals 'Header'"
End If
If txt = "Footer" Then
PrintL txt & " equals 'Footer'"
End If
PrintL "txt: <" & txt & ">"
End Sub