473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

vb 6.0 naar vb.net 2005

Hallo,

Ik probeer een programma, gemaakt in vb 6.0 te openen in vb.net 2005.
Bij het runnen zijn er enkele problemen opgetreden. Ik denk dat het
probleem bij geheugens ligt, declaratie van variabelen die bij het
omzetten naar .net zijn verandert of iets is fout gelopen. Kan het zijn
dat ik internal pointers of zo moet gebruiken? Wie kent hier iets van?
Hoe kan ik een vb 6.0 applicatie laten werken in .net 2005?

Greetz klenne

Oct 6 '06 #1
7 1383
Hi Klenne,

although Cor, opa vito, Pieter, me and some other people are able to read
your post, you probably will get more response when posting in english.

Greetz,

Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"klenne" <ba********@gmail.comschreef in bericht
news:11*********************@i3g2000cwc.googlegrou ps.com...
Hallo,

Ik probeer een programma, gemaakt in vb 6.0 te openen in vb.net 2005.
Bij het runnen zijn er enkele problemen opgetreden. Ik denk dat het
probleem bij geheugens ligt, declaratie van variabelen die bij het
omzetten naar .net zijn verandert of iets is fout gelopen. Kan het zijn
dat ik internal pointers of zo moet gebruiken? Wie kent hier iets van?
Hoe kan ik een vb 6.0 applicatie laten werken in .net 2005?

Greetz klenne

Oct 6 '06 #2
klenne wrote:

(Translation attempted by BabelFish.AltaVista.com)
I try a programme, made in vb 6.0 to open in vb.net 2005. at
managing some problems have appeared. I think that the problem lies
at geheugens, claim of variables which are at converting to net
change or something error has run. Can it be that I internal must
use pointers or this way? Who know of this does something?
How can I leave a vb 6.0 application work in net 2005?
"I try a programme, made in vb 6.0 to open in vb.net 2005"
Another failed "upgrade" attempt.

"How can I leave a vb 6.0 application work in net 2005?"
You can't.
Whilst they may share "Basic" in their names, these are two totally
separate products with radically different ways of doing things.
To get a VB2005 application that works anywhere /near/ as well as its VB
"Proper" predecessor, you are looking at rewriting it.

Regards,
Phill W.
Oct 6 '06 #3
Hallo,

I'm trying to open a program which is originally written in vb6.0, in
vb.net 2005.
When i try to run the program an error occurs. My guess is that the
problem lies in the fact that the type of adressing the memory is
changed. Therefor the translation to vb.net of the declaration of the
variables isn't correct.

perhaps its best that I will explain my program a liltle bit.

I am supposed to write a vb.net 2005 application that allows
communication between a PC (master) and a plc (slave) true the modbus
protocol with a rs232 cable.

The PC has to be able to read- write data to the plc and show it in the
program. Since the read and write error are the same I will explain the
read error.

So the basic idea is: From my main form ( where i can enter the mode
(read or write), the starting adres, number of registers i want to
read) a module is being called up (i send the mode, number of register,
starting register and such also to the module).

In this module a DLL is being called up (and again the mode, number of
register, starting register and such is send to the dll aswell) the dll
is in the system32 directory. The dll will then use the data from the
starting register, number of register to form a good modbus protocol
message.

code to enter the module with the appropriat declarations:

Private Sub ReadShort_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles ReadShort.Click
Dim BusState As Integer ' Een aantal shorts van de HPC lezen
Dim handle, j As Integer
Dim Ready As Boolean
Dim Address As TBusAddress
Dim Data As TShortData

MBRead( handle, j, 1,
mbShort,CShort(Startadress.Text),Short(numberofReg isters.Text) )

This will call up the module and go to the function MBread

Declare Function MBRead Lib "Modbus" Alias "VBMBReadRequest" (ByRef
handle As Integer, ByVal UserData As Integer, ByVal NodeNr As Short,
ByVal VarType As Short, ByVal StartAddress As Short, ByVal Count As
Short) As Short

This function forms the request that is send to the PLC, so far so
good.

Now the plc send a message back (which he actually sends, so that aint
the problem) which I will catch with the function

Ready = MBGetShorts(handle, j, BusState, Address, Data) <= is in the
main form

Again the module is being called up.

Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults"
(ByVal MBHandle As Long, ByRef UserData As Long, ByRef BusState As
Integer, ByRef Address As TBusAddress, ByRef Data As TShortData) As
Boolean

The function MBgetShorts catches the response from the plc and puts the
register data in the DATA aray. But from here it goes bad.

At the line "Ready = MBGetShorts(handle, j, BusState, Address, Data)"
the program stops and shows the error.

FATALEXECUTIONERROR:
error may be a bug in the CLR or in the unsafe or non-verifiable
portions of user code. Common sources of this bug include user
marshaling errors for COM-interop or PInvoke, which may corrupt the
stack.

The program works correct in VB6.0, you fill in the correct registers,
starting adres and mode and then the module and DLL form the request
which is send to the PLC, the plc sends a message back and the DLL and
module collect the DATA from the registers and shows it on the computer
screen.
Someone told me that it might get fixed if i used internal pointers.
Anyone knows if this will solve my problem or any other ideas???

Thx
Klenne
ps: if you dont understand me cause of my bad english phrases please
ask and ill try to reform the phrase.

Oct 6 '06 #4
klenne wrote:
Again the module is being called up.

Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults"
(ByVal MBHandle As Long, ByRef UserData As Long, ByRef BusState As
Integer, ByRef Address As TBusAddress, ByRef Data As TShortData) As
Boolean
Is this the declaration you used in VB6? If so, then it is probably
incorrect for VB.Net. Integers are now 32 bit and Longs are 64 bit.
You may wish to change them to Short and Integer respectively.

Oct 6 '06 #5
Chris Dunaway schreef:
klenne wrote:
Again the module is being called up.

Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults"
(ByVal MBHandle As Long, ByRef UserData As Long, ByRef BusState As
Integer, ByRef Address As TBusAddress, ByRef Data As TShortData) As
Boolean

Is this the declaration you used in VB6? If so, then it is probably
incorrect for VB.Net. Integers are now 32 bit and Longs are 64 bit.
You may wish to change them to Short and Integer respectively.
This is the declaration of VB.net,

the declarations for the VB6.0 are
Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults" _
(ByVal MBHandle As Long, _
ByRef UserData As Long, _
ByRef BusState As Integer, _
ByRef Address As TBusAddress, _
ByRef Data As TShortData) As Boolean

So this should be correct

Oct 6 '06 #6
klenne wrote:
Chris Dunaway schreef:
klenne wrote:
Again the module is being called up.
>
Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults"
(ByVal MBHandle As Long, ByRef UserData As Long, ByRef BusState As
Integer, ByRef Address As TBusAddress, ByRef Data As TShortData) As
Boolean
>
Is this the declaration you used in VB6? If so, then it is probably
incorrect for VB.Net. Integers are now 32 bit and Longs are 64 bit.
You may wish to change them to Short and Integer respectively.

This is the declaration of VB.net,

the declarations for the VB6.0 are
Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults" _
(ByVal MBHandle As Long, _
ByRef UserData As Long, _
ByRef BusState As Integer, _
ByRef Address As TBusAddress, _
ByRef Data As TShortData) As Boolean

So this should be correct
If that is the VB6 declaration, then your VB.Net declaration is wrong.
MBHandle should be Integer in VB.Net or even IntPtr, UserData should
be Integer, BusState should be Short. Not sure about TBusAddress and
TShortData.

Oct 6 '06 #7
Not sure about TBusAddress and TShortData.

I declared TBusAdress and TShortData like this

Structure TBusAddress
Dim NodeNr As Short
Dim VarType As Short ' mbE, mbA, mbAE, mbAA, mbMerk, mbChar, mbShort
of
mbLong
Dim StartAddress As Short
Dim VarCount As Short
End Structure

Structure TShortData
<VBFixedArray(63)Dim ShortData() As Short '
-32.. -+32.. , 2 bytes
Dim ShortData() As Short
' -32.. -+32.. , 2 bytes

Public Sub Initialize()
ReDim ShortData(63)
End Sub
End Structure

About the vbfixedArray i aint sure if thats correct

Greetz,
Klenne

Oct 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: R. van Lieshout | last post by:
Ik wil een link naar een .doc bestand maken die direct opent in MS Word en niet in de internet explorer kan iemand mij hier bij helpen want in Dream Weaver kan ik het niet vinden en na wat rond...
1
by: embee4u | last post by:
Help ! Ik gebruik een macro om een query uit te voeren naar ExceL. Dit werkt perfect. Nu wil ik echter dat het Excel-bestand als bestandsnaam de inhoud van een formulierveld gebruikt (formulier...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.