Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 December 1st, 2005, 10:13 PM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default MDI Forms

I have a value in my parent form which i want to share to my Child form. But i cannot get it to do this for me since i just started learning VB two months ago.

Help Please
Gustav Haglund

 
Old December 7th, 2005, 06:06 AM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or is this not possible?


 
Old December 7th, 2005, 03:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

there are many ways to share values, depending on the complexity of the application.
The easiest way (because you are just learning) is to declare the variable Public in the MDI form:

Public MyValue as Whatever

You can access this value everywhere in the code using

myMDI.MyValue

where myMDI is the name of the MDI form

Marco
 
Old December 7th, 2005, 05:19 PM
Authorized User
 
Join Date: Dec 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hemanth_p2p
Default

Or just put the public declration in a module in the project and pass it around.

--to marcostraf--
 Doesn't VB sometimes complain about public variables in a forms code?
 
Old December 8th, 2005, 05:49 AM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok thanks
now I have another problem
I have the text on a button thats randomized and want to share that text to another form
so would i write something like

Public btnNumber.text as what???

 
Old December 8th, 2005, 01:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't declare a property of a component as a variable!!!
Declare a public property, and in the bodu just return the text of the button:

public property get MyText() as string
MyText = btnNumber.text
end property

BTW .text is a property of the .NET command button, not VB6. What are you using?

Marco
 
Old December 8th, 2005, 01:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by hemanth_p2p

--to marcostraf--
Doesn't VB sometimes complain about public variables in a forms code?
not as I know... in fact I do it al the time. A form is just a class with a user interface.

Marco
 
Old December 8th, 2005, 02:26 PM
Authorized User
 
Join Date: Dec 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hemanth_p2p
Default

Ok, just had a doubt. Thanks for clearing it Marco.

Distributed computing ->Causality-> EventDriven ->We have the last laugh.!!
 
Old December 8th, 2005, 07:05 PM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok thank you.
I am using .NET
this worked thank you verymuch






Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI & MDI Child Forms Menu's in VB2005 yulyos Visual Studio 2005 0 September 7th, 2007 09:49 AM
MDI Forms kobystud C# 0 June 7th, 2004 04:14 AM
Mdi Forms tim33_909 Pro VB.NET 2002/2003 1 November 27th, 2003 11:40 PM
MDI Forms tim33_909 VB.NET 2002/2003 Basics 1 November 17th, 2003 03:42 PM
MDI Forms? aldwincusi VB How-To 1 September 11th, 2003 04:46 PM





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