Click here to Skip to main content
15,921,250 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am in the process of converting our software that was developed using VB6 to VB.Net. I have had some difficulties with some of the changes bu this has been the worste and I can't seem to get this working. I have found pieces of this all over the internet but every option I test, fails.

I have a VB.Net exe that reads the dll and class name from a table based on the tree node selected and loads the dll using CreateObject(). The dll contains forms and functions that I call based on the parameters that are passed and, upon exiting a function, passes a value back where I either do nothing or do something based on the returning value. This works great in VB6 and is the core of the applications' infastructure. Below is the code. Thanks in Advance.

VB6 exe Code:
PDLL = lrsLoad!DLL_ID & "." & lrsLoad!DLL_CLASS

    'use a generic object variable
    Dim objPlugIn As Object
    'Variable holds plug-ins response
    Dim strResponse As String
    'Call by prog ID. THis can be passed as ANY string whether stored in a database, typed, or Createed in code
    'The prog ID has the following format:
    [Project Name].[Class Name]
    Set objPlugIn = CreateObject(PDLL)
    'Call the generic entry proceedure
   strResponse = objPlugIn.Edit(sIniFile, sDBPath, sDataSrc, sDataBase, sDBConnType, usus, pwpw, PDPD, ID, APPTYPE, "EDIT", V1, V2)   
    If strResponse = "1" And APPTYPE = "M" Then
        Exit Sub
    ElseIf strResponse = "2" And APPTYPE "M" Then
        Exit Sub
    End If

DLL Code (Gathers info, Opens the frmConfig Dialog, the user performs a function and selects OK and the control goes back to the exe)
Public Function Edit(sINIFile As String, sDBPath As String, sDataSrc As String, sDataBase As String, sDBConnType As String, usus As String, pwpw As String, pdpd As String, ID As String, AppType As String, APPEVENT As String, V1 As String, V2 As String

  'Set All Configuration Data
  frmConfig.txtCD = V1
  frmConfig.dtpRecDT = lrsLoad!CTRK_REC_DT
  frmConfig.dtpEstStartDt = lrsLoad!CTRK_EST_START_DT
  frmConfig.dtpStartDt = lrsLoad!CTRK_START_DT
  frmConfig.dtpEstEndDt = lrsLoad!CTRK_EST_COMP_DT
  frmConfig.dtpEndDt = lrsLoad!CTRK_COMP_DT
  frmConfig.dtpRevDt = lrsLoad!CTRK_REV_DT
  frmConfig.Caption = "Configuration Tracking - " & lrsLoad!CTRK_TRACK_ID

  Screen.MousePointer = vbDefault
  frmConfig.Show vbModal

  Edit = ADODataInfo.txtDllResp

Exit Function
Updated 25-Jan-11 21:18pm
JF2015 26-Jan-11 3:18am    
Edited to add code formatting.
Patrick DePirro 26-Jan-11 8:03am    
Thanks for the response. The rely states that a minor change was made to my code but, after reviewing the response, a coulndn't recognize any changes. Can you please explain? Thanks.
Dave Kreskowiak 26-Jan-11 9:35am    
The changes were to fix formattting, not offer a fix to your problem.

Your .DLL code appears to take advantage of the Forms collection in VB6, that does not exist in VB.NET. Does the "frmConfig" form exist in the main application or in the .DLL?

Under VB6, all forms in the application exist at startup and persist through out the life of the application. In VB.NET, under OOP rules, a form only exists when an instance of it is created.

I think you've got a much deeper design issue here...
Patrick DePirro 26-Jan-11 10:08am    
Yes, the form lives in the .dll and is accessed from the main application.

Can you help? Let me know. Thanks.

1 solution

The VB6 code uses CreateObject to create an instance of a COM class that you wrote in VB6 and registered on the machine. VB.NET can do the same thing, but it's not the optimal solution.

What you're doing is essentially creating a plugin system. The code can scan a directory for plugins and dynamically load them, with going through COM to do it like you had to in VB6.

What you're apparently looking for is a plug-in framework. You can read up on them in this article[^] and this one[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900