Solved

winform events, vb.net

Posted on 2014-10-18
1
156 Views
Last Modified: 2014-10-24
The following is the list of events in my application:
 1  Form1_Load
 2  Sub FillComboboxes
 3  Sub cboCustomer_SelectedIndexChanged   
 4  Sub cboCustomer_SelectedIndexChanged
 5  Sub cboOrder_SelectedIndexChanged
 6  Sub EnableOrderQuantity
 7  Sub cboOrder_SelectedIndexChanged
 8  Sub EnableOrderQuantity
 9  Sub cboOrder_SelectedIndexChanged
10  Sub EnableOrderQuantity
11  Sub FillCustomeInfo
12  Sub TestRevised
13  Sub TestRevised
14  Sub TestRevised
15  Sub TestRevised
16  Sub TestRevised
17  Sub TestRevised
18  Sub TestRevised
19  Sub TestRevised
20  Sub EnableOrderQuantity
21  Sub FillInOrderDataGridVie

Open in new window


I have used a public variable "bolBypassCboOrder" to bypass line  "3  Sub cboCustomer_SelectedIndexChanged" via:
Private Sub cboOrder_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboOrder.SelectedIndexChanged
        strEvents += "Sub cboOrder_SelectedIndexChanged" & vbNewLine
       If bolBypassCboOrder Then
            bolBypassCboOrder = False
        Else
          ' other codes...
       End If
End Sub 

Open in new window

Q1: To produce list of events fired, is there a better way of doing that compare to my method by including a line like:
strEvents += "Sub cboOrder_SelectedIndexChanged" & vbNewLine in every event?

Q2: Is there a better way to bypass an event compared to my method of:
       If bolBypassCboOrder Then
            bolBypassCboOrder = False
        Else
          ' other codes...
       End If

Q3: Is it a good idea to supress the repeat events (line 12 through 19  Sub TestRevised)? If so, what is the best way of doing this?
0
Comment
Question by:Mike Eghtebas
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40389924
Q1:

To record what happens in an application, you normally use Debug.WriteLine instructions that send the information to the Output window. They interfere less with your application than filling up strings.

This being said, unless you have the Ultimate versions of version that has a feature called IntelliTrace that can automatically trace what happens in the application, you have to manually code the tracing as you did.

Q2:

It depends on the conditions for which you might want to bypass the event.

If the condition is set True or False only from inside the event, then it is sometimes best to declare your variable inside the event itself, by using Static instead of Dim.

Static bolBypassCboOrder As Boolean

That way, you have a local variable, that is available only inside the event and cannot be changed by mistake somewhere else in the form. But it will keep its value in between calls if needed.

Q3:

It depends on which event is triggered (the name of the Sub does not tell that), and what it does.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question