|
-
July 7th, 2001, 10:43 PM
#1
How to return value from a Form
How can I return a value or a set of values from a Modally loaded form?
Any help will be highly appreciated.
(I don't want to use global Variables)
-
July 7th, 2001, 11:06 PM
#2
Re: How to return value from a Form
Firstly, the variable must be declared public on the form. You can reference this variable using the form name on which it resides.
Ex.
On form2
Public strYourString as string
strYourString = "A form2 variable"
on form1 you can use this variable like this
text1 = form2.strYourString
'text1 will now show "A form2 variable"
David Paulson
-
July 8th, 2001, 04:09 PM
#3
Re: How to return value from a Form
write this in the form you want to return a value:
property get MyProp() as string
MyProp = "My Returned Value" 'set your value
'here
End property
and then you can access it from another form by using:
MyReturnedValue=form2.MyProp (form2 is the form that returns the value)
----------
The @host is everywhere!
----------
-
July 9th, 2001, 10:03 AM
#4
Re: How to return value from a Form
'Here another way to do it (retrieve a value from your modally loaded form)
'two forms: form1 and form2
'on each, one commandbutton (= Command1)
'form1 code
option Explicit
Dim withevents f as Form2
private Sub Command1_Click()
set f = new Form2
Load f
f.Show vbModal
set f = nothing
End Sub
private Sub f_myevent(byval strMystring as string)
MsgBox strMystring
End Sub
'-----------------
'form2 code
option Explicit
Event myevent(byval strMystring as string)
private Sub Command1_Click()
RaiseEvent myevent("ThisIsMyStringValue")
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
July 9th, 2001, 11:36 AM
#5
Re: How to return value from a Form
In From 1 - Parent form:
Private Sub cmdCallChild_Click()
dim strReturn
call frmChild.ShowForm(strReturn)
End Sub
In form 2 - Child form:
Public Sub ShowForm(ByRef strReturn as String)
Me.Show
'Return value after closing
strReturn ="Test string from the child form."
End Sub
Regards,
Michi
MCSE, MCDBA
-
July 31st, 2001, 07:01 AM
#6
Re: How to return value from a Form
hi,
More simple is you can use the "Tag" property of Form.
'in the Form1
form2.show vbModal
strVariable=Form2.Tag
'in the form2 u can store value
form2.Tag="Return Message"
regards,
Govind
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|