all groups > vb.net controls > july 2004 >
You're in the

vb.net controls

group:

Simple Newbie question- Help Please



Simple Newbie question- Help Please google.4.oracle NO[at]SPAM xoxy.net
7/16/2004 6:55:13 AM
vb.net controls: I am new to VB.net and have a simple question. I have a program with
one main form(Form1.vb) and another module (Main.vb) with a bunch of
subroutines and functions. If I want to update the text in a Textbox
(i.e. ResponseTextBox) how do a do this from outside the Form1.vb
window (i.e. from Main.vb)

If I use the following line

ResponseTextBox.Text = "Helllo"

Then I get the error that ResponseTextBox is not declared. How to I
get a pointer or a reference to ResponseTextBox.

Thanks,

Re: Simple Newbie question- Help Please Scott M.
7/16/2004 11:10:25 AM
Everything in .NET is an object. You must first make an instance of the
class that contains the textbox (dim x as new form1), then you can access
the controls on that form as properties of the class (x.ResponseTextBox.Text
= something).


[quoted text, click to view]

Re: Simple Newbie question- Help Please google.4.oracle NO[at]SPAM xoxy.net
7/17/2004 7:15:05 AM
[quoted text, click to view]

The Textbox I want to access already is an instantiated object of the
Main Form. I don't want to create a new copy of it. How do I get a
reference to the Main Form (Form1)

Re: Simple Newbie question- Help Please Scott M.
7/17/2004 11:42:58 PM
You must make an instance of the Form1 (which is just a class, not an
instance).

Dim x as new Form1
x.ResponseTextBox.Text = ???



[quoted text, click to view]

Re: Simple Newbie question- Help Please pedaammulu NO[at]SPAM yahoo.com
7/21/2004 10:02:56 PM
Hi,

Try this.

Create an instance of a form

Dim NewForm as Form1

Access the control and assign a text to the control.

NewForm.ResponseTextBox.Text = "Hello"

(Assuming ResponseTextBox is the name of the Control).

If you have any more questions email me.

I have also explained how to display a menu when an application starts
using a sub routine in my book "Database Programming using .Net and
SQL Server 2000"

Regards
Amaalu
Re: Simple Newbie question- Help Please Scott M.
7/22/2004 2:06:17 AM
Don't forget to make an instance of that Form1, right?

Dim NewForm as "New" Form1

Otherwise, you won't be able to use any of the form's instance members, only
shared members.


[quoted text, click to view]

AddThis Social Bookmark Button