Can A Form Return True / False?

mpappert

Regular
Joined
Oct 5, 2002
Messages
58
Location
Ottawa, ON, Canada
I've heard that you can somehow make a form return true or false, probably by overriding the windows form class somehow ... Here is my problem:

I have a form that I am trapping KeyPress events (turning KeyPreview On) and checking the key's for validity (this is for reading a magnetic stripe) ... it has specific characters that mark the beginning and end of the "data string" ... so I watch for these using the KeyPress event ... if I am able to get all the data successfully then I want the form to return True and go through validation, if it didn't read the swipe properly then it returns False, so a warning can be displayed to the user and they can swipe the card again ...

Any ideas?

Thanks (again)!
M.
 
The form has a built-in method for doing this. When you call ShowDialog() on a form, it returns one of many dialog result constants, the most common of which are Ok and Cancel.

In your form, as soon as you set the dialogresult, the form will hide and code will return to the calling procedure.

Visual Basic:
DialogResult = DialogResult.Cancel
'or
DialogResult = DialogResult.Ok
 
Back
Top