473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

What's the best way to make a form return a value??

What's the best way to make a form return a value.... i want to try to avoid
using module variables for doing this...

Thanks.
Alex.
Nov 20 '05 #1
9 14051
If you want to use a form like a dialog box, then you can use the showDialog
method, on the submit button you can me.hide and then on the following line
to the line calling the show method simply reference the forms members.


"Ale K." <_N******@AleK.com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
What's the best way to make a form return a value.... i want to try to avoid using module variables for doing this...

Thanks.
Alex.

Nov 20 '05 #2
Property Get/Set statements on the form class would be better, IMO.
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:#c**************@TK2MSFTNGP09.phx.gbl...
If you want to use a form like a dialog box, then you can use the showDialog method, on the submit button you can me.hide and then on the following line to the line calling the show method simply reference the forms members.


"Ale K." <_N******@AleK.com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
What's the best way to make a form return a value.... i want to try to

avoid
using module variables for doing this...

Thanks.
Alex.


Nov 20 '05 #3
Alex,
As OHM stated. You can use ShowDialog on your form.

In addition to manually calling me.Hide within the 'Submit' button, you can
have the form take care of it.

To do this you need to:
1. Set the Control.DialogResult value for your Submit/Ok button to
DialogResult.Ok
2. Set the Control.DialogResult value for your Cancel button to
DialogResult.Cancel
3. Set the Form.AcceptButton to your Submit/Ok button
4. Set the Form.CancelButton to your Cancel button

Then the form will take care of everything for you. Which ever button your
press will be the value returned from the ShowDialog call.

Dim dialog As MyDialog1
Select Case dialog.ShowDialog()
Case DialogResult.Ok
' the Submit/Ok button was pressed
Case DialogResult.Cancel
' the Submit/Ok button was pressed
' most of the time you just want to ignore cancel...
End Select
dialog.Dispose()

You can set other buttons to the other values of DialogResult and they will
be returned also. The Form's AcceptButton & CancelButton properties enable
Enter & Esc on the keyboard to be used for those buttons.

Then as OHM & Ed stated, your form class would expose properties to get the
values entered. You can use Properties to set any initial values. Similar to
how OpenFileDialog works.

Remember to call the Dispose method on your form, when you are done so that
it gets cleaned up.

Hope this helps
Jay

"Ale K." <_N******@AleK.com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
What's the best way to make a form return a value.... i want to try to avoid using module variables for doing this...

Thanks.
Alex.

Nov 20 '05 #4
Nak
> Remember to call the Dispose method on your form, when you are done so
that
it gets cleaned up.


Hi Jay,

It's interesting you should say that as I have just been wondering as of
late, is it best to dispose of *every* idisposable object?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #5
Nak,
Yes, with exceptions ;-)

My understanding is if you call Form.Show, then Form.Close will call Dispose
for you, however if you call Form.ShowDialog then Form.Close will not call
Dispose for you. As when calling Form.ShowDialog you are normally wanting to
retrieve values from the form after the form is closed. Hence you need to
manually call Dispose...

Also I understand that when the form gets disposed it disposes of all its
children.

Currently that's the only actual exception that I know of.

Jay

"Nak" <a@a.com> wrote in message
news:Ot*************@TK2MSFTNGP11.phx.gbl...
Remember to call the Dispose method on your form, when you are done so that
it gets cleaned up.


Hi Jay,

It's interesting you should say that as I have just been wondering as

of late, is it best to dispose of *every* idisposable object?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ "No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Nov 20 '05 #6
OK, but the logic still stands LMFAO

"Ed Crowley" <cu******@pacbell.net> wrote in message
news:uH**************@tk2msftngp13.phx.gbl...
Property Get/Set statements on the form class would be better, IMO.
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:#c**************@TK2MSFTNGP09.phx.gbl...
If you want to use a form like a dialog box, then you can use the

showDialog
method, on the submit button you can me.hide and then on the following

line
to the line calling the show method simply reference the forms members.


"Ale K." <_N******@AleK.com> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
What's the best way to make a form return a value.... i want to try to

avoid
using module variables for doing this...

Thanks.
Alex.



Nov 20 '05 #7
I think I'm going to Me.Dispose(). Its seems that I can never give enough
of an answer in the eyes of this group. Someone allways has do out do the
other one here.

I'm not taking away anything from the answers given here as they are
excellent if not a little verbose sometimes.

No disrespect to Jay as Jay allways give a very good answer.

But, maybe people like me should stand aside and let only the experts
answer.
Nov 20 '05 #8
OHM,
Then I need to:

GC.SupressFinalize(OHM)

Remember the ones that you consider "an expert" are learning also.
Personally one way to become an expert is to hang in there (here) and answer
questions, which is part of the reason I answer questions here. It exposes
me to aspects of the Framework that I may not normally look at.

I know I do not know every thing (read consider myself an expert), but you
did not hear that from me! :-)

Just a thought
Jay
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
I think I'm going to Me.Dispose(). Its seems that I can never give enough of an answer in the eyes of this group. Someone allways has do out do the
other one here.

I'm not taking away anything from the answers given here as they are
excellent if not a little verbose sometimes.

No disrespect to Jay as Jay allways give a very good answer.

But, maybe people like me should stand aside and let only the experts
answer.

Nov 20 '05 #9
Cor
Ed,
Property Get/Set statements on the form class would be better, IMO.

What is the sence of that

dim frm as new "dialogform"
frm.showdialog(me)
x = frm.x
frm.close
frm.dispose

It exist mostly only one click from the user.

Why take more effort than necessary with that?

Cor
Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JW | last post by:
It took me a lot of trial and error to get text from an HTML form into MySQL to account for quotation marks being entered. I came up with the following. It works fine but I was wondering if this is...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
6
by: WindAndWaves | last post by:
Hi Folks I have inhereted a script that I understand reasonably well, I just do not understand !/^\d+$/.test(el.value) what the hell does that mean? Below is the script (there are really...
8
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
4
by: brian | last post by:
i broke down where i think the problems areas would be. any help would be greatly appreciated. where the file is called <script type="text/javascript" src="k.js"> </script> the beginning...
2
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. ...
3
by: shapper | last post by:
Hello, In my Page's VB.NET code I am changing the value of the Profile property NAME. Profile.Name = tbName.Text However, I need to change this property value from a class in my App_Code...
5
by: holy moly | last post by:
Hello, I have been trying to get this JS form validation code to work ad nauseam... it won't validate, stop if required and submit. The best I managed was to get it to display an empty...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.