469,282 Members | 1,895 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Show VB6 Form from .NET - How to ?

I would wish to be able to open an existing VB6 Form from my VB.NET
application.

All VB6 forms are in COM dll. My COM dll expose a Public Class with a method
that return an instance of my VB6 form.

I have used tlbimp.exe utility to generate a RCW.(wrapper). The wrapper name
is SecurityNet

Dim objApplication As New SecurityNet.Application
Dim FormVB6 As Object
Dim FormNET As Form

FormVB6 = objApplication.GetMDIChild("frmUsers")
FormNET = CType(FVB6, Form) ---------------------------------> I get an
error: Conversion is not valid
FormNET.Show

Any help will be appreciated
TIA
Antonio
Jul 21 '05 #1
3 3228
The "Form" datatype is likely for now System.Windows.Forms.Form and not the
usual VB6 Form datatype hence this error...

You may want to add the correct namespace whatever you called it (or you
could keep late binding if you don't have anything else to do than showing
the form).

If you intended to "cast" your VB6 Form to System.Windows.Forms.Form, it
will not work (they are not "compatible" and in particular this is not the
same data type).

Patrice
--

"Antonio Paglia" <to**@algoritmo.com.ar> a écrit dans le message de
news:e8**************@TK2MSFTNGP09.phx.gbl...
I would wish to be able to open an existing VB6 Form from my VB.NET
application.

All VB6 forms are in COM dll. My COM dll expose a Public Class with a method that return an instance of my VB6 form.

I have used tlbimp.exe utility to generate a RCW.(wrapper). The wrapper name is SecurityNet

Dim objApplication As New SecurityNet.Application
Dim FormVB6 As Object
Dim FormNET As Form

FormVB6 = objApplication.GetMDIChild("frmUsers")
FormNET = CType(FVB6, Form) ---------------------------------> I get an
error: Conversion is not valid
FormNET.Show

Any help will be appreciated
TIA
Antonio

Jul 21 '05 #2
This means that COM Interop works fine only for classes but does not with
Forms ? There is a way to reuse my olds VB6 forms from NET applications ?
Antonio
"Patrice" <no****@nowhere.com> escribió en el mensaje
news:%2****************@tk2msftngp13.phx.gbl...
The "Form" datatype is likely for now System.Windows.Forms.Form and not
the
usual VB6 Form datatype hence this error...

You may want to add the correct namespace whatever you called it (or you
could keep late binding if you don't have anything else to do than showing
the form).

If you intended to "cast" your VB6 Form to System.Windows.Forms.Form, it
will not work (they are not "compatible" and in particular this is not the
same data type).

Patrice
--

"Antonio Paglia" <to**@algoritmo.com.ar> a écrit dans le message de
news:e8**************@TK2MSFTNGP09.phx.gbl...
I would wish to be able to open an existing VB6 Form from my VB.NET
application.

All VB6 forms are in COM dll. My COM dll expose a Public Class with a

method
that return an instance of my VB6 form.

I have used tlbimp.exe utility to generate a RCW.(wrapper). The wrapper

name
is SecurityNet

Dim objApplication As New SecurityNet.Application
Dim FormVB6 As Object
Dim FormNET As Form

FormVB6 = objApplication.GetMDIChild("frmUsers")
FormNET = CType(FVB6, Form) ---------------------------------> I get an
error: Conversion is not valid
FormNET.Show

Any help will be appreciated
TIA
Antonio


Jul 21 '05 #3
I meant that the problem is that you have likely a confusion between Form
(the VB6 datatype) and System.Windows.Forms.Form (which is something
different).

Here it looks like you are doing :

AWindows.Forms.Form variable = a VB6 Form Variable...

It won't work. The fact that the VB6 type and the .NET type are using the
same name doesn't make them the same type...

Unless you need to do extensive Form manipulation you could use here :

FormVB6.Show()

else see wiht the object browser what is exported by the VB6 DLL. If this is
the Form type yo(ull have to indicate the full name space to avoid a
confusuion with the .NET Form type).

Patrice
--

"Antonio Paglia" <to**@algoritmo.com.ar> a écrit dans le message de
news:eA*************@TK2MSFTNGP15.phx.gbl...
This means that COM Interop works fine only for classes but does not with
Forms ? There is a way to reuse my olds VB6 forms from NET applications ?
Antonio
"Patrice" <no****@nowhere.com> escribió en el mensaje
news:%2****************@tk2msftngp13.phx.gbl...
The "Form" datatype is likely for now System.Windows.Forms.Form and not
the
usual VB6 Form datatype hence this error...

You may want to add the correct namespace whatever you called it (or you
could keep late binding if you don't have anything else to do than showing the form).

If you intended to "cast" your VB6 Form to System.Windows.Forms.Form, it
will not work (they are not "compatible" and in particular this is not the same data type).

Patrice
--

"Antonio Paglia" <to**@algoritmo.com.ar> a écrit dans le message de
news:e8**************@TK2MSFTNGP09.phx.gbl...
I would wish to be able to open an existing VB6 Form from my VB.NET
application.

All VB6 forms are in COM dll. My COM dll expose a Public Class with a

method
that return an instance of my VB6 form.

I have used tlbimp.exe utility to generate a RCW.(wrapper). The wrapper

name
is SecurityNet

Dim objApplication As New SecurityNet.Application
Dim FormVB6 As Object
Dim FormNET As Form

FormVB6 = objApplication.GetMDIChild("frmUsers")
FormNET = CType(FVB6, Form) ---------------------------------> I get an error: Conversion is not valid
FormNET.Show

Any help will be appreciated
TIA
Antonio



Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dp | last post: by
13 posts views Thread by genetic.error | last post: by
2 posts views Thread by Ajai Kumar .R | last post: by
20 posts views Thread by WindAndWaves | last post: by
1 post views Thread by cefrancke | last post: by
reply views Thread by Homa | last post: by
13 posts views Thread by Tim Smallwood | last post: by
4 posts views Thread by Delphiscn | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.