Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Visual Basic Programming

Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-2008, 06:16 PM
reniery reniery is offline
Learning Programmer
 
Join Date: May 2008
Posts: 42
Credits: 42
Rep Power: 2
reniery is on a distinguished road
Default VB Strings

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)
Using this the only thing passed to the dll is the first letter in this case ´t´.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-15-2008, 07:13 AM
mbshinde78 mbshinde78 is offline
Newbie
 
Join Date: Sep 2008
Posts: 19
Credits: 35
Rep Power: 1
mbshinde78 is on a distinguished road
Default Re: VB Strings

Have you tried using &strTemp instead?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-16-2008, 02:27 PM
reniery reniery is offline
Learning Programmer
 
Join Date: May 2008
Posts: 42
Credits: 42
Rep Power: 2
reniery is on a distinguished road
Default Re: VB Strings

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;

}
My problem is these 2 lines, in both I need a pointer to a string and I'm having trouble doing it in vb6. Any suggestions or using my dll is the only solution.

GETDRIVERPAR(290,(LPVOID)bufSerial))
SETDRIVERPAR(290,(LPARAM)buffer))
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-25-2008, 02:27 AM
sallreen sallreen is offline
Newbie
 
Join Date: Sep 2008
Posts: 1
Credits: 2
Rep Power: 0
sallreen is on a distinguished road
Default Re: VB Strings

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-25-2008, 12:36 PM
reniery reniery is offline
Learning Programmer
 
Join Date: May 2008
Posts: 42
Credits: 42
Rep Power: 2
reniery is on a distinguished road
Default Re: VB Strings

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 10-07-2008, 03:58 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: London, England
Posts: 9,411
Last Blog:
Web slideshow in JavaS...
Credits: 2,582
Rep Power: 75
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: VB Strings

Thank you for telling me that, which I could also have found in two seconds on Wikipedia. Reporting.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-07-2008, 04:48 PM
reniery reniery is offline
Learning Programmer
 
Join Date: May 2008
Posts: 42
Credits: 42
Rep Power: 2
reniery is on a distinguished road
Default Re: VB Strings

Found what exactly ? ......
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 10-07-2008, 04:51 PM
marwex89's Avatar   
marwex89 marwex89 is offline
Guru
 
Join Date: Jul 2008
Location: Viking-land!
Posts: 3,972
Credits: 1,175
Rep Power: 30
marwex89 is a jewel in the roughmarwex89 is a jewel in the roughmarwex89 is a jewel in the rough
Send a message via AIM to marwex89
Default Re: VB Strings

I believe it was a post which were deleted. Spam. A lot of it now recently.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 10-08-2008, 04:17 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: London, England
Posts: 9,411
Last Blog:
Web slideshow in JavaS...
Credits: 2,582
Rep Power: 75
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: VB Strings

Yes, it was spam, now deleted because I reported him to Jordan.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 10-08-2008, 04:44 PM
reniery reniery is offline
Learning Programmer
 
Join Date: May 2008
Posts: 42
Credits: 42
Rep Power: 2
reniery is on a distinguished road
Default Re: VB Strings

ok... cause I thought you were refering to something I posted....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On

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


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

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads