You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old November 1st, 2007, 06:59 PM   #1
Extrasoft
Member
Brazil

Extrasoft is offline
 
Join Date: Nov 2007
Location: Vitoria
Posts: 3
Migrating VB6 IDEA app to VB.Net

Hello Experts!
I have a VB6 app that communicates (reads and writes) with the InTouch Tag Database.
The app contains only to small files, the Ptacc.bas and a test form.
The code for the Ptacc.bas file is this:

#If Win32 Then
Declare Function wwHeap_Register Lib "wwheap.dll" (ByVal hWnd As Long, ByRef NotifyMessage As Integer) As Boolean
Declare Function wwHeap_Unregister Lib "wwheap.dll" () As Boolean
Declare Function PtAccInit Lib "ptacc.dll" (ByVal hWnd As Long, ByVal nExtra As Integer) As Long
Declare Function PtAccShutdown Lib "ptacc.dll" (ByVal accid As Long) As Long
Declare Function PtAccOK Lib "ptacc.dll" (ByVal accid As Long) As Long
Declare Function PtAccHandleCreate Lib "ptacc.dll" (ByVal accid As Long, ByVal nme As String) As Long
Declare Function PtAccHandleActivate Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccHandleDeactivate Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccHandleDelete Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccActivate Lib "ptacc.dll" (ByVal accid As Long, ByVal ptname As String) As Long
Declare Function PtAccType Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccDeactivate Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccDelete Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccSetExtraInt Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer, ByVal nValue As Integer) As Long
Declare Function PtAccGetExtraInt Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer) As Long
Declare Function PtAccSetExtraLong Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer, ByVal lValue As Long) As Long
Declare Function PtAccGetExtraLong Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer) As Long
Declare Function PtAccReadD Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccReadI Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccReadR Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Single
Declare Function PtAccReadA Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Double
Declare Function PtAccReadM Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nm As String, ByVal nMax As Long) As Long
Declare Function PtAccWriteD Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Integer) As Long
Declare Function PtAccWriteI Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Long) As Long
Declare Function PtAccWriteR Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Single) As Long
Declare Function PtAccWriteA Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Double) As Long
Declare Function PtAccWriteM Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As String) As Long


#Else
Declare Function PtAccInit Lib "ptacc.dll" (ByVal hWnd As Integer, ByVal nExtra As Integer) As Long
Declare Function PtAccShutdown Lib "ptacc.dll" (ByVal accid As Long) As Integer
Declare Function PtAccOK Lib "ptacc.dll" (ByVal accid As Long) As Integer
Declare Function PtAccHandleCreate Lib "ptacc.dll" (ByVal accid As Long, ByVal nme As String) As Long
Declare Function PtAccHandleActivate Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Integer
Declare Function PtAccHandleDeactivate Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Integer
Declare Function PtAccHandleDelete Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Integer
Declare Function PtAccActivate Lib "ptacc.dll" (ByVal accid As Long, ByVal ptname As String) As Long
Declare Function PtAccDeactivate Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Integer
Declare Function PtAccDelete Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Integer
Declare Function PtAccSetExtraInt Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer, ByVal nValue As Integer) As Integer
Declare Function PtAccGetExtraInt Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer) As Integer
Declare Function PtAccSetExtraLong Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer, ByVal lValue As Long) As Long
Declare Function PtAccGetExtraLong Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nOffset As Integer) As Long
Declare Function PtAccReadD Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Integer
Declare Function PtAccReadI Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Long
Declare Function PtAccReadR Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Single
Declare Function PtAccReadA Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long) As Double
Declare Function PtAccReadM Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal nm As String, ByVal nMax As Long) As Integer
Declare Function PtAccWriteD Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Integer) As Integer
Declare Function PtAccWriteI Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Long) As Integer
Declare Function PtAccWriteA Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As Double) As Integer
Declare Function PtAccWriteM Lib "ptacc.dll" (ByVal accid As Long, ByVal hPt As Long, ByVal value As String) As Integer

#End If

The code for the test just makes use of the module above and is not important.

The questions are:
1) Does anyone know how to convert the code above to VB.Net?
2) Actually I'm not sure if converting the code would be the best approach. Is it possible to create a VB.Net wrapper that would do the job instead of converting the code above?
3) Am I right or wrong if I say that all I need to to is creating a .Net Interface that implements both InTouch dlls (ptacc.dll and wwheap.dll) used by the module above?

Any help would be very appreciated.

Thanks!
  Reply With Quote
Old November 2nd, 2007, 10:53 AM   #2
RichardB
Member
United States

RichardB is offline
 
RichardB's Avatar
 
Join Date: Jun 2004
Location: New York
Posts: 48
Those are all functions in a DLL file. Is it as simple as creating a reference in your vb.net program too reference the dll?

Then declare are veriable such as ptacc, then the program would reference the functions something like ptacc.PtAccWriteM

Not sure if its that easy or not, but seems it should be.

Good Luck,

Rich
  Reply With Quote
Old November 2nd, 2007, 11:26 AM   #3
Extrasoft
Member
Brazil

Extrasoft is offline
 
Join Date: Nov 2007
Location: Vitoria
Posts: 3
Hi Rich!
I'll try that.
Thank you!
  Reply With Quote
Old November 2nd, 2007, 01:27 PM   #4
panic mode
Member
Canada

panic mode is offline
 
panic mode's Avatar
 
Join Date: May 2003
Location: Toronto, Canada
Posts: 1,962
if you are converting it to VB.NET, you have to adjust type for some of the parameters.
for example LONG in VB6 will become INTEGER in VB.NET...
  Reply With Quote
Old November 2nd, 2007, 02:26 PM   #5
allscott
Member
Canada

allscott is offline
 
allscott's Avatar
 
Join Date: Jul 2004
Posts: 1,330
We have a similar setup with a VB app reading and writing WW tags. Our integrator told us that he tried developing a similar HMI with VB.net and went back to VB because .net was way slower.

I'm not a programmer, just letting you know what I was told.
  Reply With Quote
Old November 4th, 2007, 06:13 AM   #6
Extrasoft
Member
Brazil

Extrasoft is offline
 
Join Date: Nov 2007
Location: Vitoria
Posts: 3
Rich,
I noticed that the dlls (ptacc and wwheap) are not COM, so I cannot create references to them in VB.Net. I cannot use tblimp to create the interop code as well.
So, I decided to use the VB.Net migration tool to migrate the vb6 projet to VB.Net. The resultant project uses VB6 compatibility classes and I just fixed some errors and it is building "correctly".
Then problem now is that it is saying that the project cannot find ptacc.dll and wwheap.dll.
Any ideas?
Thank you for the tips Allscot!
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:12 AM.


.