Simple Newbie question - Please Help

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I am new to VB.net and have a basic question. I have a program with
one main form 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,

Bob
 
Hi Bob,

I think that the best answer is to make in your module something as

public sub mysub(byval as textbox)

Then from your form you can call this procedure with
mysub(responsetextbox)

In the sub you can than use the textbox completly as a textbox and set
everything or use everything. Because a textbox is an object is the
reference byvalue a reference of the object place and you can do with it
what you want. (before you think it is not a reference).

(Did yo know that the use of *response* means normaly a webform when is not
told if it isabout a winform or a webform?).

I hope this helps?

Cor
 
* (e-mail address removed) (Bob) scripsit:
I am new to VB.net and have a basic question. I have a program with
one main form 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.

If it's a control on the main form:

<URL:http://dotnet.mvps.org/dotnet/faqs/downloads/accessmainform.txt>
 
I Tried this code:

Public Class TailconeTester
Private Shared m_MainForm As MainForm

Public Shared ReadOnly Property MainForm() As MainForm
Get
Return m_MainForm
End Get
End Property

Public Shared Sub Main()
m_MainForm = New MainForm
Application.Run(m_MainForm)
End Sub
End Class

I get the error message Type "MainForm' is not defined
 
* (e-mail address removed) (Bob) scripsit:
Public Class TailconeTester
Private Shared m_MainForm As MainForm

Public Shared ReadOnly Property MainForm() As MainForm
Get
Return m_MainForm
End Get
End Property

Public Shared Sub Main()
m_MainForm = New MainForm
Application.Run(m_MainForm)
End Sub
End Class

I get the error message Type "MainForm' is not defined

Replace 'MainForm' with your main form's type.
 
Back
Top