Visual Basic Development Bookmark and Share   
 Home > Visual Basic Interop and Upgrade > Interacting with .Net Forms
 

Interacting with .Net Forms

Can a vb6 project "see" a .net form?

In vb6 I've add this code to call a vb9 form (DBLocForm - which sets the My.Settings connection string for typed datasets):

Private Sub DBLocactionClick_Click()
On Error Resume Next
Me.Hide()
Unload(Me)
DBPathTimer.enabled = True
DBPathBoolean = True
DBLocForm.SHOW()
End Sub

Private Sub DBPathTimer_Timer()
If DBPathBoolean = True Then
Dim frm As Form
For Each frm In Forms
If frm.Name = "DBLocForm" Then
Exit For
Else
Second = Second + 1
If Second > 2 Then
Call Form_Load()
Me.Visible = True
DBPathBoolean = False
DBPathTimer.enabled = False
End If
End If
Next
End If
End Sub

This seems to work in debug but fails miserably in a live version. What are my options?
DeepMaroon  Tuesday, November 10, 2009 12:56 AM
Hi DeepMaroon,

You can expose the method to VB6 so that VB6 call that method to implement your requirement.

Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byDeepMaroon Thursday, November 19, 2009 12:13 AM
  •  
Riquel_Dong  Friday, November 13, 2009 10:04 AM
Are you using the Interop Forms Toolkit?
Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Tuesday, November 10, 2009 3:08 PM
Yes I am. Thanks for you help.
DeepMaroon  Tuesday, November 10, 2009 6:38 PM
Could you explain what this code is doing? I'm not exactly sure what the Timer routine is for.
Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Wednesday, November 11, 2009 6:29 PM
Hi DeepMaroon,

You can expose the method to VB6 so that VB6 call that method to implement your requirement.

Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byDeepMaroon Thursday, November 19, 2009 12:13 AM
  •  
Riquel_Dong  Friday, November 13, 2009 10:04 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by changing the type at the top of the post window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions. Thank you!
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Tuesday, November 17, 2009 10:12 AM
On the vb6 project's main form I called an interop vb9 form "DBLocForm" that allows the user to change the program's database location. Basically it calls an OpenFileDialog where the user browses out and selects the Location of the Database on a network. The file path is then saved in a text file which is used as the connection string in opening up vb6 ADODB connections. This new locations is also saved as a UserOverride in vb9's My.Settings.[db]ConnectionString for my TableAdapter's. I needed to hide/close the vb6 project's main form and then call my vb6 project's Login form after the vb9 - DBLocForm is closed (i.e. a new db location has been selected).

Riquel, I don't know how to expose the method to vb6 other then to create an InteropUserContol. So just to test it out, I created a new InteropUserControl Project. I've create a DBPathUserControl that I put on a vb6 form and this works great. Of course this complicates things...

Now I have an InteropFormsProject and an InteropUserControlProject combined with the vb6 project on in one solution. And the Usercontrol and From projects both need to use the same My.Settings Namespace and config. This is only an issue becuase I've never tried it before so I don't know if it's possible. I am just praying that deploying the UserControl as well only requires the additions of the dll file. Is there another way I can expose the "DBPathForm" to vb6 other than to create a user control?
DeepMaroon  Thursday, November 19, 2009 12:13 AM
Hi DeepMaroon,

VB6 and VB.NET are different technologies. We can directly pass the data of simple type between two sides(for example integer and double). There is the Interop marshaller for data transferring. You can read this article for your reference about how to expose the method to vb6.
http://msdn.microsoft.com/en-us/library/bb407304(VS.80).aspx

Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Friday, November 20, 2009 6:18 AM

You can use google to search for other answers

Custom Search

More Threads

• VS2008 Inerop Conntrol Deployment problem
• VB6 interop to .NET webservice client
• "Name conflicts with existing module, project, or object library" and many Interop Toolkit UserControls
• Cannot create ActiveX component?
• char[4] for storing IPs in c language... in vb.net?
• FileNotFoundException error with pictures
• Interop Toolkit User Controls and Reg-Free COM Deployment
• XLA to XLL
• xlsheet.cells causes error when build button is used?
• VB. net and IMS Connect