form as argument

zid

Member
Joined
Mar 5, 2009
Messages
5
Programming Experience
Beginner
hi all,

I have a sub declared inside a module which accepts form as argument.

sub display(fname as form)


What I need is to call the sub form the load event of a form.
I tried the following.

display(me)

But cant access the controls of the form inside the sub.

sub display(fname as form)
fname. 'no controls of the form are listed?????????????
end sub

plz help.
 
You want to access some types members, but you only have the Form type. Options for type interacting:
  • Be specific; You can have parameter with a more specific type, for example SettingsForm.
  • Get specific; You can check the TypeOf the form in the method and DirectCast/CType it to the appropriate type.
  • Use inheritance; If you have multiple types defined that all have same members/functionality you can (a) define these in a base class that your more specific classes inherit, or (b) define an Interface and let those types implement it. Using either the base type or the interface type as parameter will grant default access to those type members.
 
Hello Mr. John,
thanks for your reply. plz give me clarification for the following.

If I send a form as an argument in a function or sub, how is it possible to access the controls on the form inside the function declaration part; for example if I want to change the text of a label control on the form, how could I refer to it?

Thank You

zid
 
Which type should that be? And why are you not using that type as method parameter instead of Form type?
 
Back
Top