Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

call a structure as function parameter

Posted on 2003-03-09
7
Medium Priority
?
221 Views
Last Modified: 2013-11-13
This is a function in C (library vbc.lib)

bool vbsend(byte* pdata, int nsize)

and this one a sample call in C

vbsend((BYTE*) &srcontrol,sizeof(srcontrol))

where srcontrol is a structure.
_____________________________________________

I translate this into VB but error..

Declare Function vbsend Lib "vbc" _
(ByVal pdata As String, ByVal nsize As Long)

rewrite srcontrol as type and call the function declared in VB

vbsend(srcontrol,len(srcontrol))

what are the right way to write this. Please help.

0
Comment
Question by:azsoft
7 Comments
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 8101103
Hi azsoft,

This article should help you with your question:

http://www.vbip.com/winsock-api/socket-send/socket-send-01.asp

Best regards, Raisor
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 8101119
Hi azsoft,

More complex source code you can find here:

http://www.activevb.de/tipps/vb6tipps/tipp0557.html

PS: Just search for "vbsend" in the code and you'll find a good example for parameter handling!

Best regards, Raisor
0
 

Author Comment

by:azsoft
ID: 8101648
Raisor,

the above C code is a working example and I'm trying to convert it into VB syntax.

thanks

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:supunr
ID: 8102148
bool vbsend(byte* pdata, int nsize)

vb equivalent

Private Declare Function vbsend Lib "vbc" _
(ByRef pdata() As Byte, ByVal nsize As Long) as Integer

Good Luck!
0
 

Author Comment

by:azsoft
ID: 8107520
pdata is a structure(type in vb), is it ok to write as pdata(). I still get an error when calling

vbsend(srcontrol,len(srcontrol))

error say that type mismatch.

help
0
 
LVL 4

Accepted Solution

by:
TigerZhao earned 750 total points
ID: 8116166
Declare Function vbsend Lib "vbc" _
(ByVal pdata As Long, ByVal nsize As Long)

vbsend(varptr(srcontrol),len(srcontrol))
0
 

Expert Comment

by:CleanupPing
ID: 8900426
azsoft:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question