Skip to main content

Pesky Multiple button clicks…

Error: I have to click the cancel(OK, Yes, No) button twice in my form.

Components used: Messagebox.show (String,String,messageboxbuttons,Icon) returns dialog result.

Example code:


Sub Main


MessageBox.Show("*Please Note: This is a really long process. Select OK continue or Cancel to exit application.", "SUBMIT CONFIRMATION", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
If (MessageBox.Show("*Please Note: This is a really long process. Select OK continue or Cancel to exit application.", "SUBMIT CONFIRMATION", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Cancel) Then
Me.Close()
Else


Do something....



End If


End Sub


Problem: The OK and Cancel buttons must be selected twice before the next line is processed.

Solution: Don’t be an idiot! You are calling this function twice! Remove the first MessageBox.Show command.











TIMER & PROGRESS BAR TIPS:

Don’t attempt to add a timer or progress bar within a long running SQL command in the same subroutine. It won’t work! You must either return status values within your SQL statement or break it up into more manageable slices using temp tables.

Cool video on Progress bars: http://www.youtube.com/watch?v=yxHrI9L9zVI&feature=related



To avoid dumb and dumber moments altogether I suggest the following material:

http://java.sun.com/docs/books/tutorial/java/concepts/index.html
http://msdn.microsoft.com/en-us/vbasic/default.aspx


If my blunders have helped you at all, please feel free to feed my ego and leave me a message.

Comments