Whenever a Code SOD featuring Visual Basic is published here, a flood of The Real WTF is VB comments ensues. As mindless and unoriginal of a comment as it is, there's a good reason for the sentiment: Visual Basic is designed for beginners, is often used by beginners, and beginners write an awful amount of awful code.

While it's easy to blame the language for bad code — *cough*PHP*cough*variableVariables*cough* — beginner-targeted languages can offer some benefits. Like, for example, the awesome fun and ease of using a single line of code like this: My.Computer.Audio.Play("cha-ching.wav")

Of course, given this snippet sent in by Albert H, there's far too much WTF to blame just the programmer.

Public Property IsDemo(Optional ByVal RuntimeInMiliSeconds As Integer = 0) As Boolean
    Return _IsDemo
  End Get
  Set(ByVal value As Boolean)

    _IsDemo = value

    If value Then
      DemoTimer.Interval = RuntimeInMiliSeconds
    End If 
  End Set
End Property

For those unacquainted with the language, VisualBasic.NET has "properties" which are used as getters and setters, much like many other modern languages. But unlike other languages, VB uses regular "()" brackets for both indexing and method parameters, leading towards code like above... and code for how such properties are used:

IsDemo(600000) = True

Naturally, a method would be just as easy (if not easier) to implement: SetDemoMode(isDemo as boolean, TimeOut as integer).

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!