[Gambas-user] Problem with OPTIONAL method declaration
Tobias Boege
taboege at ...626...
Wed Feb 4 15:35:12 CET 2015
On Wed, 04 Feb 2015, bill-lancaster wrote:
> I have a form with:-
>
> Public Sub _new(Optional iNr As Integer)
> iStatementNr = iNr
> End
>
> When the form is opened with:-
>
> Dim hForm As FFormName
> hForm = New FFormName1019)
Assuming this should read:
hForm = New FFormName(1019)
> hForm.ShowModal
>
> I get this error message - "Type mismatch: wanted control, got integer
> instead"
>
Form inherits Window and Window has an optional constructor argument (like
every widget): a parent control in which the widget should be created.
As said in the object model document[0], you need to pass the arguments for
all parent classes when you create an object -- and the arguments from the
parent class are always in front of the ones of the child class.
That is, the actual constructor of your FFormName has a signature like
FFormName._new(Optional Parent As Control, Optional iNr As Integer)
If you want your FFormName object to be an actual window, you can pass a
Null as the Parent argument.
> Wheras just:-
> FFormName.ShowModal()
> Works OK
>
This is totally different. You are using the automatic instance[1] of your
FFormName class here which is an object that was already created.
Regards,
Tobi
[0] http://gambaswiki.org/wiki/doc/object-model#t18
[1] http://gambaswiki.org/wiki/lang/createstatic
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list