Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 04:25 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem on VB.net having same structure address

Dear team,


My project is using vb6 and C language. The basic idea is using Vb to pass a structure array to DLL .


Declare Sub Machine Lib "vcdll.dll" (ByRef myStruct As MyArrayStruct)

My structure is

Structure
    Public setups(200) as integer
End Structure


This structure will to pass to VCdll and inside the DLL, its will create a thread (infinity loop). The structure data will be modified by time to time. These data will shown in VB6 display.


This project is successfully done. Any data change on VCdll will be seen in Vb (Since both holding a same address of structure.


But the problem occurred will I use VB.net. Since VB.net do not allow to fixed a structure array size. Then I have follow the declaration below


<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _

Public Structure MyArrayStruct
<VBFixedArray(199), MarshalAs(UnmanagedType.ByValArray, SizeConst:=200)> Public SETUPS() As Integer
End structure


Althrough, VB.net and VCdll able to communicate, but the data update on VB.net will not work accordingly.

For example

- VCdll (thread) => while (true){ struc.setup(0) ++; }, Vb.net can be only allow to update one time at the beginning, after end CALLBACK Machine(….)

- I suspect VB.net loss the common structure address.

-

===VCdll.dll

void __declspec(dllexport) CALLBACK Machine(struct machine *structMachine)

{

int i =1;

Pmac = structMachine;

threadID = _beginthread(PLC_PRG,1024,structMachine);

aaa = GetThreadPriority((HANDLE)threadID);


}



void PLC_PRG (void *mac)

{

i=1;

while(i)

{

Pmac ->SETUPS[0] ++;

Sleep(100);

if (Pmac ->SETUPS[0] > 100)

i=0;

}


}


The above shown Pmac ->SETUPS[0] always increment. I suppost can seen this increment in VB.net. But not the case. (Its all right in VB6).

Andbody has any idea my mistake. Please advise me. I need it urgently,


Thanks a lot

Nick





Similar Threads
Thread Thread Starter Forum Replies Last Post
find External IP Address in VB.NET remya1000 General .NET 2 March 4th, 2014 12:31 AM
classes for retriving MAC address in VB .NET mistrypremal Pro VB.NET 2002/2003 9 August 10th, 2007 12:12 PM
listen on a port to a specific IP address vb.net nmmeenaa General .NET 0 September 4th, 2006 01:16 AM
Yahoo address book Through vb.net ankesh13 Access 0 August 25th, 2006 01:27 AM
XML Address book example in vb.net p664 e4thenf4 VB Databases Basics 0 September 10th, 2004 07:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.