Click here to Skip to main content
15,890,512 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to have common Sub or Function? Pin
Paramu197310-Mar-11 1:02
Paramu197310-Mar-11 1:02 
GeneralRe: How to have common Sub or Function? Pin
Simon_Whale10-Mar-11 5:03
Simon_Whale10-Mar-11 5:03 
AnswerRe: How to have common Sub or Function? Pin
_Erik_10-Mar-11 2:38
_Erik_10-Mar-11 2:38 
AnswerRe: How to have common Sub or Function? Pin
RobCroll10-Mar-11 3:13
RobCroll10-Mar-11 3:13 
AnswerRe: How to have common Sub or Function? Pin
ghaberek18-Mar-11 7:14
ghaberek18-Mar-11 7:14 
QuestionCalling from VB.net to a Dll Win32 function that uses safearray pointer Pin
edmonson9-Mar-11 6:04
edmonson9-Mar-11 6:04 
AnswerRe: Calling from VB.net to a Dll Win32 function that uses safearray pointer Pin
_Erik_10-Mar-11 3:00
_Erik_10-Mar-11 3:00 
GeneralRe: Calling from VB.net to a Dll Win32 function that uses safearray pointer Pin
edmonson10-Mar-11 4:55
edmonson10-Mar-11 4:55 
No good result.

The translated code to VB is:

Dim CBLeds(4) As CBTipo

        CBLeds(0).Borna = 0
        CBLeds(0).Carta = 0

        Dim handleArray(4) As GCHandle
        For i As Integer = 0 To CBLeds.Length - 1
            handleArray(i) = GCHandle.Alloc(CBLeds(i), GCHandleType.Pinned)
        Next i
        Dim pointers() As IntPtr = (From handle As GCHandle In handleArray Select handle.AddrOfPinnedObject()).ToArray()
        Dim ret As Integer = EncenderLEDs(pointers, False) ' Release the handlesforeach (GCHandle handle in handleArray)    handle.Free();


        For Each handle As GCHandle In handleArray
            handle.Free()
        Next


When I Call the DLL function, the process operates normally (no exception appears) but DLL function not executes correctly.

Below you can see the code at EncenderLeds function.
I'm getting the Ubound and Lbound of array to verify that this is passed good.

The return of SafeArrayGetLBound is DISP_E_BADINDEX 8002000B
The return of SafeArrayGetUBound is DISP_E_BADINDEX 8002000B

So execution is failed.




NOMANGLE short CCONV EncenderLEDs(LPSAFEARRAY *CBLeds, bool Estado)
{
	CBTipo HUGEP *Leds;
	long LBound, UBound;
	//USHORT	MatLeds[128];
	//DWORD ReceivedBytes;
	DWORD BytesWritten;
	DATA	Adat[256];
	short	ActAdat=0;
	short nLed;
	int j;
	USHORT	ErrorCnt;
	char Cadena[200];



	for(unsigned char i=0;i<128;++i)
	{
		Adat[i].Address = 0;
		Adat[i].Data = 0;
		Adat[128+i].Address = 0;
		Adat[128+i].Data = 0;
	}

	
	int k,l;
	k=SafeArrayGetLBound(*CBLeds,1,&LBound);
	l=SafeArrayGetUBound(*CBLeds,1,&UBound);
	sprintf(Cadena,"Valores %x %x %d %d",k,l,LBound,UBound);
	MessageBox(NULL,Cadena,"Titol",0);

        return 0;
}



Any Idea what is happen?
GeneralRe: Calling from VB.net to a Dll Win32 function that uses safearray pointer Pin
_Erik_10-Mar-11 5:41
_Erik_10-Mar-11 5:41 
GeneralRe: Calling from VB.net to a Dll Win32 function that uses safearray pointer Pin
edmonson10-Mar-11 5:45
edmonson10-Mar-11 5:45 
GeneralRe: Calling from VB.net to a Dll Win32 function that uses safearray pointer Pin
_Erik_10-Mar-11 5:58
_Erik_10-Mar-11 5:58 
GeneralRe: Calling from VB.net to a Dll Win32 function that uses safearray pointer Pin
edmonson10-Mar-11 6:31
edmonson10-Mar-11 6:31 
Questionvb.net with crystal reports deployment Pin
directred7-Mar-11 1:10
directred7-Mar-11 1:10 
QuestionHow to set focus on dynamically created controls? Pin
Floodlight6-Mar-11 16:40
Floodlight6-Mar-11 16:40 
AnswerRe: How to set focus on dynamically created controls? Pin
_Erik_7-Mar-11 4:59
_Erik_7-Mar-11 4:59 
GeneralRe: How to set focus on dynamically created controls? Pin
Floodlight7-Mar-11 22:58
Floodlight7-Mar-11 22:58 
QuestionAlpha Transparent PNG form question Pin
FeRtoll5-Mar-11 5:46
FeRtoll5-Mar-11 5:46 
QuestionWindows service with FileSystemWatcher Pin
byka4-Mar-11 5:22
byka4-Mar-11 5:22 
AnswerRe:[Cross Post] Pin
Henry Minute4-Mar-11 5:53
Henry Minute4-Mar-11 5:53 
AnswerRe: Windows service with FileSystemWatcher Pin
nlarson117-Mar-11 7:26
nlarson117-Mar-11 7:26 
QuestionHow to use google map in vb.net application Pin
ejaz_pk4-Mar-11 1:03
ejaz_pk4-Mar-11 1:03 
AnswerRe: How to use google map in vb.net application Pin
Simon_Whale4-Mar-11 3:27
Simon_Whale4-Mar-11 3:27 
AnswerRe: How to use google map in vb.net application Pin
Eddy Vluggen4-Mar-11 4:39
professionalEddy Vluggen4-Mar-11 4:39 
QuestionRe: How to use google map in vb.net application Pin
ejaz_pk4-Mar-11 20:48
ejaz_pk4-Mar-11 20:48 
AnswerRe: How to use google map in vb.net application Pin
Eddy Vluggen5-Mar-11 1:36
professionalEddy Vluggen5-Mar-11 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.