By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,684 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,684 IT Pros & Developers. It's quick & easy.

passing parameters

P: n/a
Hi

How can I pass a string from a form to a dialog which I am trying to open
from the same form?

Thanks

Regards
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Cor
Hi John,
Thousand possibilties,
I just make a public string in my dialogform let say
(pseudo code)
\\\
public a as string
///
and then in the main form
\\\
dim frm as new formdialog
frm.a = "John"
frm.showdialog
dim answer as string = frm.a
frm.dispose
///
Maybe not nice, but for a dialogform I found it nice enough

I hope this helps a little 1/8 byte?
Cor
Nov 20 '05 #2

P: n/a
Excellent for my situation. Just what I was looking for. Many Thanks.

Regards
"Cor" <no*@non.com> wrote in message
news:3f***********************@reader20.wxs.nl...
Hi John,
Thousand possibilties,
I just make a public string in my dialogform let say
(pseudo code)
\\\
public a as string
///
and then in the main form
\\\
dim frm as new formdialog
frm.a = "John"
frm.showdialog
dim answer as string = frm.a
frm.dispose
///
Maybe not nice, but for a dialogform I found it nice enough

I hope this helps a little 1/8 byte?
Cor

Nov 20 '05 #3

P: n/a
"Cor" <no*@non.com> wrote in news:3f8d479f$0$25258$48b97d01
@reader20.wxs.nl:

Hi Cor,

I think he wanted to pass the string TO the dialog.

One way would be to overload the ShowDialog method to take a string and
pass in the string when the dialog form is shown:

'In the dialog form

Private m_SomeString As String

Public Overloads Function ShowDialog(sParm As String) As DialogResult
m_SomeString = sParm
Return MyBase.ShowDialog()
End Function
'Then in the form that opens the dialog,
' pass in the string to the constructor:

Dim fDialog As New DialogForm()

fDialog.ShowDialog("String to pass to the Dialog")
HTH

Chris
Nov 20 '05 #4

P: n/a
Cor
Chris,
I think he wanted to pass the string TO the dialog.


I did in my exampe, TO and FROM.
\\\
frm.a = "John"
frm.showdialog
dim answer as string = frm.a
///

I know it is not nice but that dialogbox lives just some seconds.

And mostly it is a very simple form,

When it would be a special dialogclass for all dialogs, I would sure do it
in the way you describe.

Cor

Nov 20 '05 #5

P: n/a
"Cor" <no*@non.com> wrote in
news:3f***********************@reader20.wxs.nl:
I did in my exampe, TO and FROM.


My mistake, I didn't read closely enough.

Chris
Nov 20 '05 #6

P: n/a
John,
As Cor stated you can use a Property, which is consistent with the Framework
(OpenFileDialog for example).

In addition to the property I will also sometimes add an overloaded
constructor to the dialog that accepts the value I want to pass in. However
I normally only use this when I am passing readonly data, such as the
caption of the dialog or a reference to an object that the dialog operates
on. Because the object is a reference the dialog can modify the object
itself.

Hope this helps
Jay

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Hi

How can I pass a string from a form to a dialog which I am trying to open
from the same form?

Thanks

Regards

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.