Home
Sound - Did you know that a message box automatically plays a beep?
  v1.0 Posted at 27/11/2012 1:58 PM by Rebecca Liu
Windows plays sounds for message boxes
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

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments: