|
||||||
| Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I've been working in integrating my vb6 app with a scanner and have come upon a small problem. I´m using the dll´s provided by the scanner manufacturer.
Ok what i'm trying to do is pass a string variable to a dll. This is from the sdk documentation To set a string, use a pointer to the string. To get the string, allocate 256 bytes of memory and set a pointer to that memory. The string is copied to the memory. This I think is my problem Code:
strTemp="test" ScannerPrint STRING, StrPtr(strTemp) The reason is cause strptr only returns the adress in memory of the first char in the string so how do I pass the whole string. Help please ![]() |
| Sponsored Links |
|
|
|
|||
|
Have you tried using &strTemp instead?
__________________
Manoj Shinde My Command Button ActiveX | My Frame Panel ActiveX | My Screen Capture ActiveX |
|
|||
|
No I haven't tried &strtemp, but I'll try it right now.
Btw I found the solution for my problem, I used a c++ dll and then I just call it from my vb app. But is there a way to do this in vb6 directly, this are the functions I did in my c++ dll Code:
BSTR __stdcall testFunction(BSTR stringVar)
{
LPSTR buffer;
buffer = (LPSTR)stringVar;
if (OK!=SETDRIVERPAR(290,(LPARAM)buffer)){
::MessageBox(NULL,"Error asignando ","Error",0);
}
else{
}
//buffer = _strrev(buffer);
return(SysAllocString(stringVar));
}
BSTR __stdcall testGetSerial()
{
unsigned char bufSerial[255];
if (OK!=GETDRIVERPAR(290,(LPVOID)bufSerial)){
::MessageBox(NULL,"Error retrieving Serial ","Error",0);
}
else{
}
return (BSTR)bufSerial;
}
GETDRIVERPAR(290,(LPVOID)bufSerial)) SETDRIVERPAR(290,(LPARAM)buffer)) |
|
|||
|
A string is a data type consisting of a series of characters. While we treat it as a simple data parameter, it is in reality closely related to an array. In fact, some other languages (such as C++), force the developer to manipulate strings as if they were arrays. In VB, strings are treated as a variable, the same way an integer, for example, would be treated.
---------------------- Sally drivenwide |
|
|||
|
Yeah but there is a difference in structure in how strings are handle in vb and in c++. For example C strings are arrays of characters terminated by a NULL character. Visual Basic strings differ in that the length of the string preceded the characters in the string. C++ BSTR is the same as the String in VB so im using that in my c++ dll.
But actually my problem is with using pointers in vb6, what I need to do is a pointer to a string but until now I have only been able to point to the first char of the string using strptr() . In c++ I did it using the code a previously posted but haven´t found a vb6 equivalent yet. So is it posible On a side note: VB I despise you ![]() |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| vB Weekly Stats Version 1.7 | Jordan | Community Projects | 51 | 02-11-2008 12:25 PM |
| VB vs VB.Net | Patrick | Visual Basic Programming | 2 | 10-14-2007 12:58 PM |
| VB 6.0: Tutorial, Explaining the VB 6.0 GUI | TcM | VB Tutorials | 1 | 05-18-2007 11:25 AM |
| VB strings to C DLL | malachi1984 | Visual Basic Programming | 0 | 05-11-2007 06:36 AM |
| Strings | clookid | PHP Tutorials | 2 | 01-13-2007 04:23 PM |
| WingedPanther | ........ | 2662.49 |
| Xav | ........ | 2581.51 |
| Brandon W | ........ | 1698.26 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 959.05 |
| dcs | ........ | 646.09 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 409.29 |
| chili5 | ........ | 380.6 |
Goal: 100,000 Posts
Complete: 97%