?
Solved

call a structure as function parameter

Posted on 2003-03-09
7
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

771 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