Mirage Source
Redundant? - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+----- Thread: Redundant? (/showthread.php?tid=2465)



Redundant? - Nean - 01-01-2009

Code:
Private Sub chkServerLog_Click()
    ' if its not 0, then its true
    If Not chkServerLog.Value Then
        ServerLog = True
    Else
        ServerLog = False
    End If
End Sub

Wouldn't it be simpler to just see if it's checked, rather than toggle a boolean when it's checked? Rather than seeing if the ServerLog = True or false, why not just have it as

Code:
If frmserver.chkserverlog.value = 1 Then
DoCode

Am I missing something obvious?


Re: Redundant? - Matt - 01-01-2009

It's less code in the long run, if you think about it. I'd rather just check a single boolean (I prefer to use a byte..) than have to type all that out each time.


Re: Redundant? - Labmonkey - 01-01-2009

Less code in vb6 doesn't actually mean its faster. But really, it will make such an insignificant difference. Just ignore it.


Re: Redundant? - Matt - 01-01-2009

Who said anything about speed? I'm just lazy. Lol.


Re: Redundant? - Nean - 01-01-2009

Hmmm. Alright, just trying to learn good habits for programming. Figured, I'd ask you guys. Thanks!


Re: Redundant? - GIAKEN - 01-01-2009

You know to reduce that to a single line?

Code:
Private Sub chkServerLog_Click()
    ' if its not 0, then its true
    ServerLog = Not chkServerLog.Value
End Sub