Rules

Secret ingredients to quality software

Edit
Info

Sound - Did you know that a message box automatically plays a beep?

Created on 27 Nov 2012 | Last updated by Rebecca Liu on 27 Nov 2012 02:58 AM (over 8 years ago)

Win7SoundError
Figure: Good Example - Windows message boxes plays a sound... which cannot be captured in screenshot form.

A message box automatically provides this functionality so there is no need to manually put a beep right before a message box pops up.

Dim Message As String = "You did not enter a server name. Cancel this operation?"
        Dim Caption As String = "No Server Name Specified"
        Dim Buttons As Integer = MessageBoxButtons.YesNo
        Beep()
        result = MessageBox.Show( Me, Message, Caption, Buttons)

Figure: Bad example - The sound on the button is hardcoded in this code snippet

Dim Message As String = "You did not enter a server name. Cancel this operation?"
        Dim Caption As String = "No Server Name Specified"
        Dim Buttons As Integer = MessageBoxButtons.YesNo
        result = MessageBox.Show( Me, Message, Caption, Buttons)

Figure: The code is not present in this example as it is automatically done


We open source. This page is on GitHub