Unnecessary code...

Posted by Martin Milan on Stack Overflow See other posts from Stack Overflow or by Martin Milan
Published on 2010-03-19T10:37:59Z Indexed on 2010/03/19 10:41 UTC
Read the original article Hit count: 199

Filed under:

Suppose I have some code that looks like this:

Private Sub MySub()
    dim blnFlag as Boolean

    blnFlag = False     
    for each item in collection
        if item.Name = "Mike" then 
            blnFound = true
            exit for
        endif
    next item

End Sub

Now - the blnFLag = False assignment is not actually necessary - booleans are initialised as false, but I think it's inclusion makes the code easier to read. What's your opinion?

© Stack Overflow or respective owner

Related posts about subjective