Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 14th, 2004, 12:19 AM
Authorized User
 
Join Date: Dec 2003
Location: sg petani, kedah, Malaysia.
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
Reply With Quote
  #2 (permalink)  
Old May 14th, 2004, 07:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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
Reply With Quote
  #3 (permalink)  
Old May 14th, 2004, 08:16 AM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
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)
Reply With Quote
  #4 (permalink)  
Old May 15th, 2004, 12:26 AM
Authorized User
 
Join Date: Dec 2003
Location: sg petani, kedah, Malaysia.
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
Reply With Quote
  #5 (permalink)  
Old May 15th, 2004, 08:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #6 (permalink)  
Old May 17th, 2004, 08:15 AM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
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.
Reply With Quote
  #7 (permalink)  
Old May 17th, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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
Reply With Quote
  #8 (permalink)  
Old May 17th, 2004, 08:28 PM
Authorized User
 
Join Date: Dec 2003
Location: sg petani, kedah, Malaysia.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:54 AM.


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