472,796 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

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 3411
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dp | last post by:
I am new to VB.NET and I have a simple question. How do I show a form from a command button click event? The code I have below is not working. I am trying to show the form frmAgent. What am I...
13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
20
by: WindAndWaves | last post by:
Hi Gurus I was wondering if you can send me in the right direction: I have a table with about 300 rows. I want to make all of them invisible and when a user enters a code in a form then make...
1
by: cefrancke | last post by:
I have set the Startup properties to the following... All menus, toolbars, etc are turned off plus these are unchecked Allow Full Menus Allow Built-in Toolbars Allow Default Shortcut Menus...
0
by: Homa | last post by:
Hi I'm working on a program that will have 3 forms: a main form, a status form and a sub-form. The main form and status form are always appear, and my sub-form is a singleton (for performance...
13
by: Tim Smallwood | last post by:
Hi, This is probably a stupid question, but I can't seem to get a form to show / load? In the older versions of VB I'd use frmMyform.show / load myForm, etc? I looked at the help file and it...
3
by: yzi | last post by:
I have a list form and a detail form . Before, I open the List form, use form.showDialog(),then I click List Item and open the Detail Form by form.show(). now , user need when the list form...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
4
by: Delphiscn | last post by:
How to show a ABOUT Form???????? Hello Everyone: I use C# want to Create a Project. In my project. there are two forms. One is main form, and another is a about form. In the about form there...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.