 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 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
|
|
|
|

May 14th, 2004, 12:19 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
passing parameter..
I have 2 form, form1 and form2.
How can I pass a value from form1 to form2?
information : (form1 - have a value price)(form2 - have label1)
for now I'm using:
Dim frm1 As New form2
frm1.label1.text = price
Do u know another solution that more easy and efficient? because there's also a few parameter that I want to pass to form2.
:D Suzila
__________________
 Suzila
|
|

May 14th, 2004, 07:14 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
You can use a function in form2 (such as SetValues) and pass the values in as parameters. Make sure the function is Public or Friend scope.
Brian
|
|

May 14th, 2004, 08:16 AM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You could also just add a property to Form2 and set it from Form1(or any other form for that matter)
|
|

May 15th, 2004, 12:26 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
bmains,
can I just call a function from form1 and passing parameter to form 2?
can you give some example..
BSkelding,
I can't see what you tell me about..can you give me some clues..
Thanks so much for both of you
:D Suzila
|
|

May 15th, 2004, 08:39 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Here is an example of where something like what you want is posted. Check this and see if it helps:
http://p2p.wrox.com/topic.asp?TOPIC_ID=9924
J
|
|

May 17th, 2004, 08:15 AM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
'First you need to declare a modular variable on Form2 -
'you can use what ever type is appropriate
Dim mstrValue As String
'create your property
Property Value() As String
Get
Return mstrValue
End Get
Set(ByVal Value As String)
mstrValue = Value
End Set
End Property
You can then access this property from your other forms,functions,etc
Let me know if you have any more questions.
|
|

May 17th, 2004, 11:14 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
In form2, you declare:
Public Sub SetValue(intValue1, strValue2)
m_intValue1 = intValue1
m_strValue2 = strValue2
End Sub
and in form 1, you do:
objForm2.SetValue(intI, "String Value")
something like that. Relaly, either properties or methods are fine. It's up to you to define how you want to do it.
Brian
|
|

May 17th, 2004, 08:28 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
katsarosj,BSkelding,bmains
Thank You..It's works
:D Suzila
|
|
 |