Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Raise Event issue...

Posted on 2012-04-01
3
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
appari earned 1600 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 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 400 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 34

Author Closing Comment

by:Mike Eghtebas
ID: 37794547
Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

722 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