473,407 Members | 2,598 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,407 software developers and data experts.

How do I write to a textbox in a form from within a class

I have a form with one button, Button1, and a Textbox, Textbox1

I have a class, class1 as follows.

Public Class Class1
Public DeForm As Object
Sub doit()
DeForm.Textbox1.text = "It works"
End Sub
End Class

My button code is as follows

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeForm = Me
XX.doit()
End Sub

Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be
written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not found."

on this line.

DeForm.Textbox1.text = "It works"

Can someone help?

thanks

Hamil.

Nov 21 '05 #1
19 1946
Hi Hamil,

That is because Textbox1 isn't Public so Class1 can't refer to it. Try
this:

Public Class Class1
Public DeTextbox As Object
Sub doit()
DeTextbox.Text = "It works"
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeTextbox = Textbox1
XX.doit()
End Sub

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
I have a form with one button, Button1, and a Textbox, Textbox1

I have a class, class1 as follows.

Public Class Class1
Public DeForm As Object
Sub doit()
DeForm.Textbox1.text = "It works"
End Sub
End Class

My button code is as follows

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeForm = Me
XX.doit()
End Sub

Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be
written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not found."
on this line.

DeForm.Textbox1.text = "It works"

Can someone help?

thanks

Hamil.

Nov 21 '05 #2

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be
written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not
found."

on this line.

DeForm.Textbox1.text = "It works"

Can someone help?


You can change the Modifiers property to Friend.
Nov 21 '05 #3


"Jeff Johnson [MVP:VB]" wrote:

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be
written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not
found."

on this line.

DeForm.Textbox1.text = "It works"

Can someone help?


You can change the Modifiers property to Friend.

Could you explain. Modifiers of what??

Hamil.

Nov 21 '05 #4

Ken What you suggest works! Could you explain the problem in a bit more
detail. Your example is similar to what I wrote except that I tried to pass
the entire form object and you passed only the TestBox1 object.

Is there a way to pass the entire form so if I have a number of textboxes in
the form I can pass the entire form by setting one object variable?

I'm new to VB.net so excuse me if I am not saying things exactly correct.
"Ken Dopierala Jr." wrote:
Hi Hamil,

That is because Textbox1 isn't Public so Class1 can't refer to it. Try
this:

Public Class Class1
Public DeTextbox As Object
Sub doit()
DeTextbox.Text = "It works"
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeTextbox = Textbox1
XX.doit()
End Sub

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
I have a form with one button, Button1, and a Textbox, Textbox1

I have a class, class1 as follows.

Public Class Class1
Public DeForm As Object
Sub doit()
DeForm.Textbox1.text = "It works"
End Sub
End Class

My button code is as follows

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeForm = Me
XX.doit()
End Sub

Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be
written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not

found."

on this line.

DeForm.Textbox1.text = "It works"

Can someone help?

thanks

Hamil.


Nov 21 '05 #5
Hamil,

It is jumping in the blind however
\\\
Sub doit()
For Each ctr As Control In DeForm.Controls
If ctr.Text = "TextBox1" Then
ctr.Text = "It works"
End If
Next
End Sub
///
I hope this helps?

Cor

"hamil" <ha***@discussions.microsoft.com>
I have a form with one button, Button1, and a Textbox, Textbox1

I have a class, class1 as follows.

Public Class Class1
Public DeForm As Object
Sub doit()
DeForm.Textbox1.text = "It works"
End Sub
End Class

My button code is as follows

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeForm = Me
XX.doit()
End Sub

Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be
written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not
found."

on this line.

DeForm.Textbox1.text = "It works"

Can someone help?

thanks

Hamil.

Nov 21 '05 #6
Hi,

Here is another way to do it:

Public Class Class1
Public DeForm As Form1 'The class name of your form.
Sub doit()
DeForm.Textbox1.Text = "It works"
End Sub
End Class

Then in your Button1 Click event change your code back to the original:

Dim XX As New Class1
XX.DeForm = Me
XX.doit()

This will let you access all the controls on the form. The problem was that
the controls are declared as Friend, so in order to access them you need to
declare the DeForm as Form1 instead of just a generic object. You do not
want to modify the Friend modifier in the Form itself to read public because
that messes things up. For example I tried that in VB.Net 2002 and it would
remove the controls from my form so I had to recreate them again. Good
luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...

Ken What you suggest works! Could you explain the problem in a bit more
detail. Your example is similar to what I wrote except that I tried to pass the entire form object and you passed only the TestBox1 object.

Is there a way to pass the entire form so if I have a number of textboxes in the form I can pass the entire form by setting one object variable?

I'm new to VB.net so excuse me if I am not saying things exactly correct.
"Ken Dopierala Jr." wrote:
Hi Hamil,

That is because Textbox1 isn't Public so Class1 can't refer to it. Try
this:

Public Class Class1
Public DeTextbox As Object
Sub doit()
DeTextbox.Text = "It works"
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeTextbox = Textbox1
XX.doit()
End Sub

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
I have a form with one button, Button1, and a Textbox, Textbox1

I have a class, class1 as follows.

Public Class Class1
Public DeForm As Object
Sub doit()
DeForm.Textbox1.text = "It works"
End Sub
End Class

My button code is as follows

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeForm = Me
XX.doit()
End Sub

Here is what I want to happen..

When I press Button1, Class1 is instanciated as XX.
Then i send a reference of my form to XX in object variable DeForm .
Now when DoIt is executed, I would like the test string "it works" to be written in the textbox1 on me form, that is named Form1.

When it runs I get this error message.

"Additional information: Public member 'Textbox1' on type 'Form1' not

found."

on this line.

DeForm.Textbox1.text = "It works"

Can someone help?

thanks

Hamil.


Nov 21 '05 #7
Ken,

Problem is that in your solution the class is not real reusable, (what it is
in my solution as well not much because that textbox needs forever the name
"textbox1")

However when it is used to transport information from one form class to the
other, than this is a solution.

Not that you do not know that however for the ones who read this thread
later.

Cor

Nov 21 '05 #8

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
You can change the Modifiers property to Friend.

Could you explain. Modifiers of what??


The control you want to access from the class. In the Properties window of
the IDE (with the form designer window open), select the control and then
find the Modifiers property.
Nov 21 '05 #9
"hamil" <ha***@discussions.microsoft.com> wrote in message news:<BC**********************************@microso ft.com>...
Ken What you suggest works! Could you explain the problem in a bit more
detail. Your example is similar to what I wrote except that I tried to pass
the entire form object and you passed only the TestBox1 object.

Is there a way to pass the entire form so if I have a number of textboxes in
the form I can pass the entire form by setting one object variable?

I'm new to VB.net so excuse me if I am not saying things exactly correct.


The following should help clear things up a bit. When you design a
class, you can control the level of access for each class member.
Class members are class variables, properties, events, methods (subs
and functions), etc.

You can specify whether a class member is:
1) Public
2) Private
3) Protected
4) Friend
5) Protected Friend

This list is known as "modifiers", because they modify the member's
level of access.

For example:

Class MyClass
Private PrivateVar As Integer
Public PublicVar As Integer
Protected ProtectedVar As Integer
Friend FriendVar As Integer
End Class

Class MyOtherClass
Public Sub DoThis(mc As MyClass)
mc.PublicVar = 1 '<--- OK because it is Public
mc.PrivateVar = 1 '<-- illegal because this is private to
MyClass
mc.ProtectedVar = '<-- illegal because this is private to
MyClass and its derived classes
mc.FriendVar = 1 '<-- OK as long as MyOtherClass is in same
project/assembly as MyClass
End Sub
End Class

"Public" means that the member can be accessed from anywhere ...
inside or outside the class, and inside or outside the
project/assembly. This is the one end of the spectrum. In the example
above, MyOtherClass can access MyClass.PublicVar because it is Public.

"Private" means that the member can only be access from within the
class itself. This is the opposite end of the spectrum from Public. In
the example above, MyOtherClass cannot access MyClass.PrivateVar
because PrivateVar is private to MyClass; only code inside MyClass is
allowed to access PrivateVar.

"Protected" is the same as 'private', except that derived classes can
also access the member. Consider the following class:

Class MySimiliarClass
Inherits MyClass
Public Sub DoSomething()
Me.ProtectedVar = 1 '<--- OK because member is protected
(accessible by class and derived classes only)
Me.PublicVar = 1 '<--- OK because member is public
Me.PrivateVar = 1 '<-- illegal because member is private to
MyClass
Me.FriendVar = 1 '<-- OK as long as MySimiliarClass is in
same project/assembly as MyClass
End Sub
End Class

"Friend" is much like 'public' in that any code within the same
project/assembly can access Friend members. However, code outside the
project/assembly cannot access these members.

"Protected Friend" combines 'Protected' and 'Friend', such that
Protected Friend members can be accessed by any code inside the same
project/assembly and also by any derived classes that are defined in a
different project/assembly.
Now, to your TextBox issue ... In your form that contains your Button,
your text box control is defined as a "Private" member. Your form *is*
a class, and the TextBox is a member of your form's class. If you look
at the code generated by the form designer, you would see something
like the following:

Private TextBox1 As TextBox

Because this textbox member is 'Private', other classes (such as your
Class1 class) cannot access it. Remember, Private members can only be
accessed by code within the class itself. Therefore, your TextBox can
only be accessed by the code in your form.

Now, if you were to use the Properties window and change the TextBox
from 'Private' to 'Friend' or 'Public', then your Class1 could access
the textbox. ('Friend' would be better, because you want to use the
most restrictive modifier that provides the required level of access,
but not more than is needed).

The reason why it worked when passing the TextBox reference to the
routine instead of the form reference, is because in that case you are
not accessing the text box through the form object.

If you change the modifier for all text boxes you need to work with in
this manner from 'Private' to 'Friend', then your Class1 class would
be able to accept a reference to your form and manipulate those text
boxes as needed.

Does that help clarify things a bit?
Nov 21 '05 #10
This is real close to what I want, however as Cor points out, the clas is not
reusable. It seems like there should be a way to make my original method
work by making some sort of change, i.e. friend to public like you
discouraged.

In your first reply, you pointed out that I could pass a reference to a
particular Textbox to the class and it works. When I tried to pass the
entire form as an object from which I could pick out the textbox of my choice
it failed.

Any thoughts.
Hamil.


"Ken Dopierala Jr." wrote:
Hi,

Here is another way to do it:

Public Class Class1
Public DeForm As Form1 'The class name of your form.
Sub doit()
DeForm.Textbox1.Text = "It works"
End Sub
End Class

Then in your Button1 Click event change your code back to the original:

Dim XX As New Class1
XX.DeForm = Me
XX.doit()

This will let you access all the controls on the form. The problem was that
the controls are declared as Friend, so in order to access them you need to
declare the DeForm as Form1 instead of just a generic object. You do not
want to modify the Friend modifier in the Form itself to read public because
that messes things up. For example I tried that in VB.Net 2002 and it would
remove the controls from my form so I had to recreate them again. Good
luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...

Ken What you suggest works! Could you explain the problem in a bit more
detail. Your example is similar to what I wrote except that I tried to

pass
the entire form object and you passed only the TestBox1 object.

Is there a way to pass the entire form so if I have a number of textboxes

in
the form I can pass the entire form by setting one object variable?

I'm new to VB.net so excuse me if I am not saying things exactly correct.
"Ken Dopierala Jr." wrote:
Hi Hamil,

That is because Textbox1 isn't Public so Class1 can't refer to it. Try
this:

Public Class Class1
Public DeTextbox As Object
Sub doit()
DeTextbox.Text = "It works"
End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim XX As New Class1
XX.DeTextbox = Textbox1
XX.doit()
End Sub

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
> I have a form with one button, Button1, and a Textbox, Textbox1
>
> I have a class, class1 as follows.
>
> Public Class Class1
> Public DeForm As Object
> Sub doit()
> DeForm.Textbox1.text = "It works"
> End Sub
> End Class
>
> My button code is as follows
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click
> Dim XX As New Class1
> XX.DeForm = Me
> XX.doit()
> End Sub
>
> Here is what I want to happen..
>
> When I press Button1, Class1 is instanciated as XX.
> Then i send a reference of my form to XX in object variable DeForm .
> Now when DoIt is executed, I would like the test string "it works" to be > written in the textbox1 on me form, that is named Form1.
>
> When it runs I get this error message.
>
> "Additional information: Public member 'Textbox1' on type 'Form1' not
found."
>
> on this line.
>
> DeForm.Textbox1.text = "It works"
>
> Can someone help?
>
> thanks
>
> Hamil.
>
>
>


Nov 21 '05 #11
Hi,

Change Friend to Public the way Jeff Johnson recommended. I think I was
having problems because I was modifying the code where is says not to modify
it. Using the Modifiers property from the property box is the correct way
to do it. Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
This is real close to what I want, however as Cor points out, the clas is not reusable. It seems like there should be a way to make my original method
work by making some sort of change, i.e. friend to public like you
discouraged.

In your first reply, you pointed out that I could pass a reference to a
particular Textbox to the class and it works. When I tried to pass the
entire form as an object from which I could pick out the textbox of my choice it failed.

Any thoughts.
Hamil.


"Ken Dopierala Jr." wrote:
Hi,

Here is another way to do it:

Public Class Class1
Public DeForm As Form1 'The class name of your form.
Sub doit()
DeForm.Textbox1.Text = "It works"
End Sub
End Class

Then in your Button1 Click event change your code back to the original:

Dim XX As New Class1
XX.DeForm = Me
XX.doit()

This will let you access all the controls on the form. The problem was that the controls are declared as Friend, so in order to access them you need to declare the DeForm as Form1 instead of just a generic object. You do not want to modify the Friend modifier in the Form itself to read public because that messes things up. For example I tried that in VB.Net 2002 and it would remove the controls from my form so I had to recreate them again. Good
luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"hamil" <ha***@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...

Ken What you suggest works! Could you explain the problem in a bit more detail. Your example is similar to what I wrote except that I tried to

pass
the entire form object and you passed only the TestBox1 object.

Is there a way to pass the entire form so if I have a number of textboxes
in
the form I can pass the entire form by setting one object variable?

I'm new to VB.net so excuse me if I am not saying things exactly
correct.

"Ken Dopierala Jr." wrote:

> Hi Hamil,
>
> That is because Textbox1 isn't Public so Class1 can't refer to it. Try > this:
>
> Public Class Class1
> Public DeTextbox As Object
> Sub doit()
> DeTextbox.Text = "It works"
> End Sub
> End Class
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim XX As New Class1
> XX.DeTextbox = Textbox1
> XX.doit()
> End Sub
>
> Good luck! Ken.
>
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
>
> "hamil" <ha***@discussions.microsoft.com> wrote in message
> news:D3**********************************@microsof t.com...
> > I have a form with one button, Button1, and a Textbox, Textbox1
> >
> > I have a class, class1 as follows.
> >
> > Public Class Class1
> > Public DeForm As Object
> > Sub doit()
> > DeForm.Textbox1.text = "It works"
> > End Sub
> > End Class
> >
> > My button code is as follows
> >
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > Dim XX As New Class1
> > XX.DeForm = Me
> > XX.doit()
> > End Sub
> >
> > Here is what I want to happen..
> >
> > When I press Button1, Class1 is instanciated as XX.
> > Then i send a reference of my form to XX in object variable DeForm
.. > > Now when DoIt is executed, I would like the test string "it works" to be
> > written in the textbox1 on me form, that is named Form1.
> >
> > When it runs I get this error message.
> >
> > "Additional information: Public member 'Textbox1' on type 'Form1'

not > found."
> >
> > on this line.
> >
> > DeForm.Textbox1.text = "It works"
> >
> > Can someone help?
> >
> > thanks
> >
> > Hamil.
> >
> >
> >
>
>
>


Nov 21 '05 #12
Ken,
Change Friend to Public the way Jeff Johnson recommended. I think I was
having problems because I was modifying the code where is says not to
modify
it. Using the Modifiers property from the property box is the correct way
to do it. Ken.


Why Ken, the textbox1 is unknow to the form class it is in its inherrited
class Form1, however not known in the parentclass Form.

Your answer was the best direct answer in my opinion, however it gives not
much results as long as that not is between two forms.

Cor
Nov 21 '05 #13
Jef
The control you want to access from the class. In the Properties window of
the IDE (with the form designer window open), select the control and then
find the Modifiers property.

????

Cor
Nov 21 '05 #14
"Cor Ligthert" <no************@planet.nl> schrieb:
The control you want to access from the class.
In the Properties window of the IDE (with the
form designer window open), select the control and then
find the Modifiers property.

????


???

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #15
???
Means that I do not understand this and I am active in this thread,
something I learned from Herfried K. Wagner

Cor
Nov 21 '05 #16
Hi Cor,

That's true. Late-binding would be used and you would lose intellisense by
declaring the form variable in the class as object. But now the class would
be universal and you can always check to see what type of form you have and
knowing that use Textbox1 if you know that form contains one. I'd put in
some Try...Catch blocks to make sure I could easily spot bugs where I try to
reference a Textbox1 on a form that didn't have one. But now the class is
reusable without having to know the actual form it works with. Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Ken,
Change Friend to Public the way Jeff Johnson recommended. I think I was
having problems because I was modifying the code where is says not to
modify
it. Using the Modifiers property from the property box is the correct way to do it. Ken.


Why Ken, the textbox1 is unknow to the form class it is in its inherrited
class Form1, however not known in the parentclass Form.

Your answer was the best direct answer in my opinion, however it gives not
much results as long as that not is between two forms.

Cor

Nov 21 '05 #17

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
The control you want to access from the class. In the Properties window
of the IDE (with the form designer window open), select the control and
then find the Modifiers property.
????


Okay, perhaps this is a little clearer. I'll go step-by-step, using object
names from the original post:

1. Make sure the designer window for Form1 is open and active.
2. Select Button1, either by clicking on it in the designer window or
selecting it from the dropdown in the Properties window.
3. Find the Modifiers property and change it to Friend. If your Properties
window is in Categorized view (which I personally don't like) then you'll
find it in the Design category.

In case your misunderstanding was simply with the first sentence, it was in
answer to the poster's question of
Modifiers of what??

Nov 21 '05 #18


"Jeff Johnson [MVP:VB]" wrote:

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
The control you want to access from the class. In the Properties window
of the IDE (with the form designer window open), select the control and
then find the Modifiers property.
????


Okay, perhaps this is a little clearer. I'll go step-by-step, using object
names from the original post:

1. Make sure the designer window for Form1 is open and active.
2. Select Button1, either by clicking on it in the designer window or
selecting it from the dropdown in the Properties window.
3. Find the Modifiers property and change it to Friend. If your Properties
window is in Categorized view (which I personally don't like) then you'll
find it in the Design category.

In case your misunderstanding was simply with the first sentence, it was in
answer to the poster's question of
Modifiers of what??



First, I want to thank all of you for your help. I have learned a lot in
the discussions. In the above though, I think Jeff means to change the
modifier of the TextBox1 from friend to public (correct me if this is wrong).
This is what I did and it works.

I also found out that in my class I could change the line

Public Deform as object

to

Public DeForm as Form1

where Form1 is the form where my button and textbox resides.
and then the Textbox is visible in the class. So I have lots of ways to do
things. :-)
Hamil.
Nov 21 '05 #19
Hamil,

Public Deform as object

to

Public DeForm as Form1


The last statement which you got from Ken is why it works, not the change
from friend to public, that will help you when the procedure is outside your
project. Inside a project is a Friend the same as Public.

However the first answer from Ken was the best when it has to be a generic
class, but then only with option Strict off.

Just to get no wrong conclussions in this thread.

Cor

Nov 21 '05 #20

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

Similar topics

14
by: Gidi | last post by:
Hi, For the last week, i'm looking for a way to make a TextBox always write in English (No matter what the OS default language is). i asked here few times but the answers i got didn't help me. i...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
3
by: The One | last post by:
Have created a form to pop up with 2 option I then wish to write the text that is in the option button chose back to the original form using the code below but it gives me an exception error so...
2
by: Steve | last post by:
Hello, If I instantiate a class object from a form I would like to be able to write to a label on the calling form something like "hello from class object" from within a subroutine inside...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
3
by: DotNetNewbie | last post by:
I am reading the book Teach Yourself Microsoft Visual Basic .Net 2003 in 21 Days. I am having trouble getting one of the exercises to work at the end of day 4. Exercises: 1. Create a new...
3
by: JoelH | last post by:
This is really weird... I'm using Visual Basic 2005 Express I have a form - Form1 - with a control called txtStatusBox I have a module attached to the solution for storing some other code. This...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
5
by: =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?= | last post by:
I'm sorry, but I've read your code a couple of times and just don't see where the Form1 is initialized. Form1 also sounds like a class name, and this would be how you could do some form operations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.