Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2010, 01:31 AM
Authorized User
 
Join Date: Dec 2006
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Default messagebox appears twice

Code:
PrivateSub chkFabric_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkFabric.CheckedChanged
IfNot IsNumeric(txtPrice.Text) Then
chkFabric.Checked = False
MessageBox.Show("Please Correct the price")
ExitSub
EndIf
addprice()
EndSub



This text box contains a string "20 to 25"
User is expected to correct the price by typing a number between 20 to 25 in the text box. When this sub executes it checks if the user has entered the correct number in the text box. If it is not a numeric data then it forces the user to correct the data in text box.
When this sub executes the messagebox appears twice.
I would appreciate if somebody corrects the code but I would be greatfull they explain me why is it happening.
__________________
yvk
 
Old October 14th, 2010, 07:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

When you are manually correcting the checked, you are calling this sub again.. That's why you see two message box.
Add a boolean value at the start that tell you when you are inside this function to avoid entering again when you are still procesing it...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
The Following User Says Thank You to gbianchi For This Useful Post:
Yasho (October 14th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Include a column if it appears more than once... SpyderSL Access 20 June 3rd, 2008 10:06 AM
Parameter Entry Page Still Appears yazzy Crystal Reports 1 June 26th, 2007 02:53 AM
(Collection) appears in the list box Tracey BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 April 30th, 2007 09:53 AM
Weird whitespace appears in TEXTAREA, why? jacob XSLT 3 November 10th, 2005 08:25 PM
"Ghost Form Appears" dbkester Access 2 October 3rd, 2003 09:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.