From: Mr. X. on
As "Family Tree Mike" said:

> Inside the if-then-else you know it is a form, so do the coding as
> follows:
>
> sub bla (byval t as type)
> if (t is gettype(Form)) then
> dim x as new Form
> x.ShowDialog()
> end if
> end sub
>
> --
> Mike

The problem is :
What t parameter has related to the code you gave ?
(The only occurrence is its declaration : byval t as type).

Thanks :)

From: Family Tree Mike on
On 4/24/2010 11:04 AM, Mr. X. wrote:
> As "Family Tree Mike" said:
>
>> Inside the if-then-else you know it is a form, so do the coding as
>> follows:
>>
>> sub bla (byval t as type)
>> if (t is gettype(Form)) then
>> dim x as new Form
>> x.ShowDialog()
>> end if
>> end sub
>>
>> --
>> Mike
>
> The problem is :
> What t parameter has related to the code you gave ?
> (The only occurrence is its declaration : byval t as type).
>
> Thanks :)

I don't understand your question unless you simply misread the statement
"if (t is gettype(Form)) then". You seemed to be wanting to create an
object x based on the type passed to the function as t. Your function
could be expanded to something like:

sub bla (byva t as type)
if (t is gettype(Form)) then
dim x as new Form
x.ShowDialog()
else if (t is gettype(Button)) then
dim x as new Button
this.Controls.Add(x)
else if (t is gettype(MySpecialControl)) then
dim x as new MySpecialControl
' do something specific to this control type...
end if
end sub

--
Mike
From: Mr. X. on
Sorry. It's my English.

I need the solution for the line you gave:
"else if (t is gettype(MySpecialControl)) then"
but ...
dim x as new MySpecialControl compiled,
but in code, I don't know t is MySpecialControl.
What I know t is a child of form (or a child of MySpecialControl) - that's
enough, and I want to make new instance of the child.

Something like :
If T Is GetType(MySpecialControl) Then
Dim x As New T.GetTypeOfChild() ... what should I write here ?
End If


Thanks :)


"Family Tree Mike" <FamilyTreeMike(a)ThisOldHouse.com> wrote in message
news:#mOQ#b84KHA.4520(a)TK2MSFTNGP02.phx.gbl...
> On 4/24/2010 11:04 AM, Mr. X. wrote:
>> As "Family Tree Mike" said:
>>
>>> Inside the if-then-else you know it is a form, so do the coding as
>>> follows:
>>>
>>> sub bla (byval t as type)
>>> if (t is gettype(Form)) then
>>> dim x as new Form
>>> x.ShowDialog()
>>> end if
>>> end sub
>>>
>>> --
>>> Mike
>>
>> The problem is :
>> What t parameter has related to the code you gave ?
>> (The only occurrence is its declaration : byval t as type).
>>
>> Thanks :)
>
> I don't understand your question unless you simply misread the statement
> "if (t is gettype(Form)) then". You seemed to be wanting to create an
> object x based on the type passed to the function as t. Your function
> could be expanded to something like:
>
> sub bla (byva t as type)
> if (t is gettype(Form)) then
> dim x as new Form
> x.ShowDialog()
> else if (t is gettype(Button)) then
> dim x as new Button
> this.Controls.Add(x)
> else if (t is gettype(MySpecialControl)) then
> dim x as new MySpecialControl
> ' do something specific to this control type...
> end if
> end sub
>
> --
> Mike

From: Armin Zingler on
Am 24.04.2010 18:44, schrieb Mr. X.:
> Sorry. It's my English.
>
> I need the solution for the line you gave:
> "else if (t is gettype(MySpecialControl)) then"
> but ...
> dim x as new MySpecialControl compiled,
> but in code, I don't know t is MySpecialControl.
> What I know t is a child of form (or a child of MySpecialControl) - that's
> enough, and I want to make new instance of the child.
>
> Something like :
> If T Is GetType(MySpecialControl) Then
> Dim x As New T.GetTypeOfChild() ... what should I write here ?
> End If

"Child" means it is a derived class? If you know the type is Form, how do you know
the type of the child? Because there can be many classes derived from the Form class.

If you know the type in the calling method, why don't you create an instance in
the calling method? And where does the calling method know the type from?

In the end, what is your intention?


--
Armin
From: Mr. X. on
There is a derived "form" control of mine.
Any of the derived form has additional functionality (some methods ...
working with DB, etc ...)

There may be many forms of the derived form.
Each time I need to do : newForm.ShowDialog.
Only need to pass the type, and no need to create the form on the calling
program
(Each form has it's own elements, buttons, etc. and look different from
other forms).

Thanks :)

"Armin Zingler" <az.nospam(a)freenet.de> wrote in message
news:eB5irE94KHA.6132(a)TK2MSFTNGP05.phx.gbl...
> Am 24.04.2010 18:44, schrieb Mr. X.:
>> Sorry. It's my English.
>>
>> I need the solution for the line you gave:
>> "else if (t is gettype(MySpecialControl)) then"
>> but ...
>> dim x as new MySpecialControl compiled,
>> but in code, I don't know t is MySpecialControl.
>> What I know t is a child of form (or a child of MySpecialControl) -
>> that's
>> enough, and I want to make new instance of the child.
>>
>> Something like :
>> If T Is GetType(MySpecialControl) Then
>> Dim x As New T.GetTypeOfChild() ... what should I write here
>> ?
>> End If
>
> "Child" means it is a derived class? If you know the type is Form, how do
> you know
> the type of the child? Because there can be many classes derived from the
> Form class.
>
> If you know the type in the calling method, why don't you create an
> instance in
> the calling method? And where does the calling method know the type from?
>
> In the end, what is your intention?
>
>
> --
> Armin