Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

winform events, vb.net

Posted on 2014-10-18
1
Medium Priority
?
161 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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