Creating forms as objects and accessing their members in VB

  • Thread starter Thread starter Geoff Callaghan
  • Start date Start date
G

Geoff Callaghan

I am trying to create a form object, and then modify some custom members
before I show the form. Everything compiles fine, but when I run it, I get
an error suggesting the object doesn't exist yet. The form load event does
not run until I Show the form. This makes no sense, since I am explicitly
creating the form
by doing a PUBLIC OBJECTINST AS OBJECTTYPE.

What's going on here?
 
by doing a PUBLIC OBJECTINST AS OBJECTTYPE.

Your sample declares but does not create. Try something like
Dim f As Form1
f = New Form1
f.CustomMember = SomeValue
f.Show

or sticking with your example
PUBLIC OBJECTINST AS NEW OBJECTTYPE

If you need more help, provide the code that does not work for you so we can
comment on it

None of the above is CF-specific so you could also try the VB ng:
microsoft.public.dotnet.languages.vb

Cheers
Daniel
 
Back
Top