The variable 'GroupBox1' is either undeclared or was never assigned.

N

nsikkandar

I created a Child Form and added several controls. One of the control
is GroupBox1. When I want to change the access modifier property of the
GroupBox1

FROM

"Public WithEvents GroupBox3 As System.Windows.Forms.GroupBox"

TO

"Public Shared WithEvents GroupBox3 As System.Windows.Forms.GroupBox"

Note down "Shared" added....

When i am executing, it did not produce any error.

When I go back to design window, it produced following error

D:\DOTNET\vbnet\Part2\Form2.vb(621): The variable 'GroupBox1' is either
undeclared or was never assigned.


I donot understand this error.

Kindly let me know how to fix it.

Many thanks in advance
 
A

Armin Zingler

I created a Child Form and added several controls. One of the
control is GroupBox1. When I want to change the access modifier
property of the GroupBox1

FROM

"Public WithEvents GroupBox3 As System.Windows.Forms.GroupBox"

TO

"Public Shared WithEvents GroupBox3 As
System.Windows.Forms.GroupBox"

Note down "Shared" added....

When i am executing, it did not produce any error.

When I go back to design window, it produced following error

D:\DOTNET\vbnet\Part2\Form2.vb(621): The variable 'GroupBox1' is
either undeclared or was never assigned.


I donot understand this error.

A shared groupbox does not make sense. Where is the Groupbox if you don't
have a Form? Where is it if you have multiple Forms? In addition, you must
not modify the code generated by the Form designer.

Kindly let me know how to fix it.

Remove the Shared keyword.


Armin
 
C

Cerebrus

"Public Shared WithEvents GroupBox3 As System.Windows.Forms.GroupBox"
Note down "Shared" added....

Now, why in the world would you want a "shared" GroupBox !!?

Shared elements are not associated with a specific instance of a class
or structure.

Regards,

Cerebrus.
 
N

nsikkandar

I just want create a NewClass where I want to validate the members of
groupbox1 of Form2 ...

Thanks
 
C

Cerebrus

Hi nsikkander,

What are the "members" of your GroupBox ? Controls, I presume. And your
Controls must have associated values (Text etc.) that you want to
validate.

Well, in that case, why not store the values in some sort of collection
(Maybe... Arraylist ?) and then pass that collection to a
method/function in your NewClass, which can then return a Boolean True
or False depending on the Validation result.

In any case, a GroupBox cannot be Shared. Inherited maybe, but not
Shared.

Regards,

Cerebrus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top