Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
| Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 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 March 11th, 2008, 11:30 AM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
Default To pass value of string variable to another form

Hi all
Thank you for all your help and I have learnt a lot so far.
Now I am trying to pass the value of the selection - a string variable - to another form. Information from form1 is about what to play ie word, spell or math. The value of the variable will be one of these three words. I need to pass this to the next from so this form can modify depending on which game to play.
My problem is I am unable to pass this string variable value from form1 to form2. Any help is very much appriciated.
Thanks
thillai

 
Old March 11th, 2008, 01:59 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

And what have you tried so far?

Is the form already open? Do you want to open the form with the value?

One way is to create an instance of the form, then call a method on it that receives the value in question. This method initializes the form based on the data passed in and then calls the method to show itself.

-Peter
peterlanoie.blog
 
Old March 12th, 2008, 10:39 AM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi peter
Thanks for the reply. The form1 allows user to select one of three options ie word, spell and math. Once the selection is made and button clicked, another form loads- form2- and I want the selection from form1 to be passed to form2.
Cannot make it work, Please help.
Thanks
thillai

 
Old March 12th, 2008, 01:04 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Thillai,

I understand what you are trying to do. But you still have not shown us what you have tried so far. You say you cannot make it work. How is it not working? Can you post the relevant code you are trying to use? That will help us help you.

-Peter
peterlanoie.blog
 
Old March 12th, 2008, 03:24 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

(I don’t mean to horn in here, Peter. But, that said . . .)

Thillai,

When you load the second form, the 1st form is still loaded. You can read the values of the controls on the first from directly be referencing the name of the form, the name of the control, and the name of the property you are examining. Let's say form 1 is frmOne, and the control is a text box named txtValue. In form two, you can reference frmOne.txtValue.Text to read that control. The same applies to check boxes and radio buttons.
 
Old March 13th, 2008, 03:29 AM
Authorized User
 
Join Date: Feb 2008
Location: , , .
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi all
Yes I have done it using Brian's method; In form2 I wrote strChoice=Form1.txtSelection.Text, where strChoice is a string variable defined in form2, txtSelection is the textbox in form1 where selection is made.
Thanks all.
I am learning every time I have a doubt.
thillai





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass variable to main form dataset spacky001 ASP.NET 1.0 and 1.1 Basics 2 September 13th, 2006 10:10 PM
pass form elements variable vickyj Classic ASP Basics 0 October 29th, 2005 04:58 AM
Can't pass query string variable on secure server gnilly BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 August 24th, 2005 11:18 AM
Pass Form Variable to Report (DataReport) coboy VB How-To 1 September 22nd, 2004 12:19 PM
How to pass a variable form one form to the next Dinesh22 VB.NET 2002/2003 Basics 1 January 8th, 2004 08:55 PM





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