473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help with forms

Ok.. extremly new to NET so bear with me )

In VB5 you could do this

(in Form2)
form1.text1.text = "test"
now how do you change textbox propertys from another part
of code - like from a module or another form?

Thanks-
Noramn
Nov 20 '05 #1
4 1412
First you need to make sure that text1's access modifier is set to public
(Public text1 As TextBox). After you do that, Form2 just needs to have a
reference to form1 somehow. There's a few different ways they could be
related.

If Form2 is a child of form1 (code goes in Form2):
Dim myForm1 As Form1 = Me.Parent
myForm1.TextBox1.Text = "Hi from form 2!"

If Form2 is owned by form1 (code goes in Form2):
Dim myForm1 As Form1 = Me.Owner
myForm1.TextBox1.Text = "Hi from form 2!"

You can create a property on Form2 like this:
Private _myForm As Form1

Public Property MyForm() As Form1
Get
MyForm = _myForm
End Get
Set(ByVal Value As Form1)
_myForm = Value
End Set
End Property

Then you just need to make sure you set that property before you try to
access it.

Good luck!

"Wooten26" <wo******@nospam-yahoo.com> wrote in message
news:17****************************@phx.gbl...
Ok.. extremly new to NET so bear with me )

In VB5 you could do this

(in Form2)
form1.text1.text = "test"
now how do you change textbox propertys from another part
of code - like from a module or another form?

Thanks-
Noramn

Nov 20 '05 #2
First you need to make sure that text1's access modifier is set to public
(Public text1 As TextBox). After you do that, Form2 just needs to have a
reference to form1 somehow. There's a few different ways they could be
related.

If Form2 is a child of form1 (code goes in Form2):
Dim myForm1 As Form1 = Me.Parent
myForm1.TextBox1.Text = "Hi from form 2!"

If Form2 is owned by form1 (code goes in Form2):
Dim myForm1 As Form1 = Me.Owner
myForm1.TextBox1.Text = "Hi from form 2!"

You can create a property on Form2 like this:
Private _myForm As Form1

Public Property MyForm() As Form1
Get
MyForm = _myForm
End Get
Set(ByVal Value As Form1)
_myForm = Value
End Set
End Property

Then you just need to make sure you set that property before you try to
access it.

Good luck!

"Wooten26" <wo******@nospam-yahoo.com> wrote in message
news:17****************************@phx.gbl...
Ok.. extremly new to NET so bear with me )

In VB5 you could do this

(in Form2)
form1.text1.text = "test"
now how do you change textbox propertys from another part
of code - like from a module or another form?

Thanks-
Noramn

Nov 20 '05 #3
Hi Wooten,

In addition to Andy.

In VB.net are 3 types of forms.
The one opened with show, the ones opened with showdialog, and the MDI forms
(parent and child)

http://msdn.microsoft.com/library/de...tarwinform.asp

The one Andy provided you is the MDI

I hope this helps?

Cor
Nov 20 '05 #4
"Wooten26" <wo******@nospam-yahoo.com> schrieb
Ok.. extremly new to NET so bear with me )

In VB5 you could do this

(in Form2)
form1.text1.text = "test"
now how do you change textbox propertys from another part
of code - like from a module or another form?


If you want to access an object, you need a reference. If you don't have
one, make it available, usually by passing the reference as a procedure
argument or to a property.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sudheer Kareem | last post by:
Dear All Please tell me how to assosiate help files with my Vb.net Project. Regards Sudheer
2
by: Anita C | last post by:
Hi, How do I associate or map a specific column in a datatable to a particular element present in an xml document - to read into a datatable as well as write from the datatable to the xml element?...
7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
5
by: MFC | last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key of C#, and C# Weekend Crash Course) and three weeks, I believe I have tried everything to make a certain form function...
2
by: Brian | last post by:
I am very new to VB.NET and I just need some help in a listbox matter. I don't need suggestions on how to make the overall code better. I will get there. I want to move an item from one list box...
8
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
6
by: cj | last post by:
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class . It gives an example at the bottom that begins with:...
0
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools...
9
by: Ringo | last post by:
the LeafProject http://www.leafproject.org has a DLL for Face recognition. it is written in C++ but they interface to it from Lisp. I want to interface to it from C#. Their Lisp definitions looks...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.