[Gambas-user] Creating a new form instance in code + and Case
richard terry
rterry at ...1946...
Thu Sep 1 14:02:23 CEST 2011
Hi benoit.
In the code tree one of my forms, for arguments sake, my work cover form is
called FWorkCover (note the capitalisation)
I've a subroutine, pivotal to my clinical program where I add new instances of
forms onto my main workspace workspace, using this sort of logic:
Public sub Add_Page(pagename as string)
Dim Form_Workcover as FWorkcover (note the C not capitalised as I'd typed it
wrongly)
Select case pagename
case "workcover"
Form_Workcover = new FWorkcover (some_container)
End select
end
ie when i did the original Dim Form_Workcover I'd typed Fworkcover (no caps
for the C in workcover, instead of FWorkCover which is the name in the code
tree. This didn't seem to affect anything at all.
In another part of my program I had occasion to test which form was active on
the workspace tab, and, according to its name, activate or inactivate buttons
for new, print,preview etc like as follows. I'd assumed, that as in the code
tree the form was FWorkCover, that was the name I'd be testing for (not
realising that I'd not capped the 'C' of FWorkcover in the other routine.
For Each page In WorkspaceEditor.Windows
If page = WorkspaceEditor.ActiveWindow Then
For Each hctrl In page.VBoxEditor.Children
If hctrl Is Form Then
Select Case hctrl.Name
Case "FWorkCover"
'activate appropriate buttons etc
End Select
I kept on getting inconsistant results and when I checked it out, I noticed
that hctrl.name here was "FWorkcover"
when i went back and corrected the original name, it was then FWorkCover and
worked.
So the question is how come it is possible to create a new instance of a form,
when not using the exactly capitalised name fo the original form?
Hope that makes sense
Regards
Richard
More information about the User
mailing list