Wrox Programmer Forums
|
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
 
Old May 14th, 2004, 12:19 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default 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
 
Old May 14th, 2004, 07:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
 
Old May 14th, 2004, 08:16 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could also just add a property to Form2 and set it from Form1(or any other form for that matter)
 
Old May 15th, 2004, 12:26 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default

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
 
Old May 15th, 2004, 08:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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
 
Old May 17th, 2004, 08:15 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'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.
 
Old May 17th, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
 
Old May 17th, 2004, 08:28 PM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default

katsarosj,BSkelding,bmains
Thank You..It's works

:D Suzila





Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameter sarah lee ASP.NET 1.0 and 1.1 Basics 3 September 5th, 2006 04:29 PM
problem with passing parameter hertendreef ADO.NET 0 June 23rd, 2006 10:00 AM
Passing a Date Parameter ego_mouse BOOK: Professional Crystal Reports for VS.NET 1 January 27th, 2005 08:12 AM
Parameter passing psambor Beginning PHP 0 September 17th, 2003 01:47 AM
Passing Parameter tgopal Javascript 3 August 7th, 2003 07:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.