Working with legacy code I came across some strange variable assignments that I am not sure are legal VB6 syntax, but I cannot find the documentation to back up the feeling.
Dim ComStart, ComEnd, CR As Boolean
ComStart = ComEnd = CR = False
My suspicions are
a) the original declarations should be
Dim ComStart as Boolean, ComEnd as Boolean, CR as Boolean
b) the declarations as they are implemented now will not assign anything to ComStart.
Any answers or documentation are much appreciated
The code you have found is technically legal VB6, because it compiles and runs. But it is very likely that the original author thought the code would do something different! There are two misunderstandings.
ComStartandComEndandCRare variants, not Booleans.=is the equality operator, not the assignment operator found in C.CR = Falsedoes not change the value ofCR. It compares the current value ofCRtoFalse, and evaluates asTrueifCRis equal toFalse. Let’s say it evaluates asFalseComEnd = False. Again, this does not change the value ofComEnd. It compares it withFalse, and evaluates asTrueifComEndis equal toFalse. This time let’s say it evaluates asTrue.ComStart = True. This sets the value ofComStarttoTrueSo your original code
Creates two variants
ComStartandComEndand a BooleanCR, and thenCRkeeps its default value,FalseComEndkeeps its default value,EmptyComStartis set toFalsebecauseEmpty = (Empty = False)isFalse.Simple! … I hope the rest of the legacy code is less, well, accidental.