Parameter with type "Variant" equals anything?
issueid=333 12-11-2011 22:16
Member
Number of reported issues by dcromley: 6
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
Issue Details
Issue Number 333
Project thinBasic
Category Core engine (thinCore.dll)
Status Under investigation
Priority 8
Affected Version 1.8.9
Fixed Version (none)
Milestone (none)
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




13-11-2011 11:51
Issue Changed by ErosOlmi
  • Status changed from Unconfirmed to Under investigation

+ Reply