Solved

Raise Event issue...

Posted on 2012-04-01
3
259 Views
Last Modified: 2012-04-01
To see the problem, consider following the following steps:

1.      Click “Default Values” button
2.      Click on “Create Car” button.
3.      Click on “Drive” button.
4.      Enter 210 miles. Click ok.
5.      After 210 miles gas level drops down to 3 miles.
6.      There is a raise event to inform the user to pump gas (if less or 5 gal.)

The problem is that the warning comes up two times.

Question: How can I correct it so that the low gas warning will come up only once?

Thank you.
CarClass.txt
FormCode.txt
frmMyCar.vb
0
Comment
Question by:Mike Eghtebas
3 Comments
 
LVL 39

Accepted Solution

by:
appari earned 400 total points
ID: 37794506
change this part in your frmCar1.vb code

Sub LowGasMessage() Handles myCar.LowGasLevel
        MessageBox.Show("Pump gas, after driving, you will have only 5 gallons of gas left.", "Low Gas Warnning...", _
                        MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End Sub

TO, no need to write handles ....


Sub LowGasMessage()
        MessageBox.Show("Pump gas, after driving, you will have only 5 gallons of gas left.", "Low Gas Warnning...", _
                        MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Sub
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 total points
ID: 37794520
You have "myCar" declared as WithEvents and correctly paired with a Handles clause to trap the LowGasLevel event.

Therefore you do NOT need AddHandler and RemoveHandler at lines #106 and #108.  Get rid of both of those.
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 37794547
Thank you
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Open a folder with partial name 14 29
Library to convert HTML to PDF. 8 44
Getfiles in vb.net 28 18
Close word object 13 9
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now