Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Migrate from vb6 to vb.net problem

Status
Not open for further replies.

amigo02

Programmer
Feb 19, 2003
109
I have a vb6 component with following code



Public objContext As COMSVCSLib.ObjectContext
Public Request As Object
Public session As Object
Public Application As Object
Public Server As Object
Private rs As ADODB.Recordset

Public Function Init()
Set objContext = GetObjectContext()
Set Request = objContext.Item("Request")
Set session = objContext.Item("Session")
Set Application = objContext.Item("Application")
Set Server = objContext.Item("Server")

Set rs = New ADODB.Recordset
Set conn = oConn


End Function


when I upgrade it to vb.net it becomes as follows;

Public Function Init() As Object
Public Request As Object
Public session As Object
Public Application As Object
Public Server As Object
Private rs As ADODB.Recordset

Public Function Init() As Object
objContext = COMSVCSLibAppServer_definst.GetObjectContext()
Request = objContext.Item("Request")
session = objContext.Item("Session")
Application = objContext.Item("Application")
Server = objContext.Item("Server")
rs = New ADODB.Recordset()
conn = oConn

End Function


but in converted vb.net project I can't access the request, session, application and server object's properties and methods.

What am I doing wrong!

Additionaly during upgrade vb.net added a new file into the project with the following code;

Module UpgradeSupport
Friend COMSVCSLibGetSecurityCallContextAppObject_definst As New COMSVCSLib.GetSecurityCallContextAppObject
Friend COMSVCSLibAppServer_definst As New COMSVCSLib.AppServer
Friend OutlookApplication_definst As New Outlook.Application
End Module

Please help......
 
Move the code in your "init" process to the "Public Sub New" method.

When you want to access your objects in that class, make sure you first instantiate the class:
dim MyClass1 as New MyClass

Then you should be able to access the Public members through dot notation:
MyClass1.Server

This FAQ may be helpful in understanding how Classes and instantiations work:
-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top