Home All Groups Group Topic Archive Search About

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

Author
26 Feb 2006 9:27 AM
nsikkandar@gmail.com
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

Author
26 Feb 2006 10:46 AM
Armin Zingler
<nsikkan***@gmail.com> schrieb
Show quoteHide quote
> 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
Author
26 Feb 2006 11:39 AM
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.
Author
26 Feb 2006 7:17 PM
nsikkandar@gmail.com
I just want create a NewClass where I want to validate the members of
groupbox1 of Form2 ...

Thanks
Author
27 Feb 2006 6:55 AM
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.
Author
27 Feb 2006 7:29 AM
nsikkandar@gmail.com
Many thanks Cerebrus. It sounds good idea.
Author
27 Feb 2006 7:44 AM
Cerebrus
Most welcome, buddy ! ;-)

Happy coding,

Regards,

Cerebrus.