Solved

How to get the returned value ?

Posted on 2002-05-23
5
123 Views
Last Modified: 2010-05-02
Hi ,

I have the following VB Program :

Private Declare Function ICS_InsertDocumentB Lib "iwdll" _
(ByVal pszServerName As String, _
ByVal pszUserName As String, _
ByVal pszPassword As String, _
ByVal pszDirID As String, _
ByVal pszTitle As String, _
ByVal pszFilePath As String, _
ByVal pszDocPublished As String, Optional ByVal fSSLEnable As Long = 0, _
Optional ByVal JpegQuality As Long = 400, _
Optional ByVal TypeConversion As Long = 4, _
Optional ByVal HtmlConversion As Long = 1, _
Optional ByVal InsideFolder As Long = 0, _
Optional ByVal HideDoc As Long = 0, _
Optional ByVal pszDocKey As String = vbNullString, _
Optional ByVal pszDocDescr As String = vbNullString, _
Optional ByVal iClassID As Long = 0, _
Optional ByVal pszNumbers As String = "1Emp5ty9", _
Optional ByVal pszTexts As String = "1Emp5ty9", _
Optional ByVal pszDates As String = "1Emp5ty9", _
Optional ByVal pszBlobs As String = "1Emp5ty9", _
Optional ByVal pszStyleID As String = "1Emp5ty9", _
Optional ByVal iPosition As Long = 1, _
Optional ByVal iRank As Long = 50, _
Optional ByVal pszDateExpire As String = vbNullString, _
Optional ByVal pszDateDeferred As String = vbNullString) As Long



Private Sub Form_Load()

nerrorr = ICS_InsertDocumentB("OpenShare", "administrator", "44444444", "1", "test", "c:\vba\install.log", pszDocPublished)
MsgBox (nerrorr)
Unload Me

End Sub


It is working fine but the problem is that the function is returning the value called "pszDocPublished"

How can I read this value If I do MsgBox (pszDocPublished) it returns nothing although it should returns something

My Question is how to read this value

Thnx
0
Comment
Question by:marounk
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:Nitin Sontakke
ID: 7029346
There are few things to note.

01. For a function to return a value in a variable passed as a parameter, it is important that the parameter has ByRef in declaration as against ByVal. The parameter "pszDocPublished" is called ByVal and cannot possibly return a value.

02. pszDocPublished is a parameter name. You should declare a string variable and then pass it to function. So, you should have following in code.

Dim strDocPublished as String

and then pass strDocPublished in place of pszDocPublished.

If you wish to avoid this kind of error in future type 'Option Explicit' at the beginning of the code.

I hope this helps.

0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 150 total points
ID: 7029403
I guess that the DLL is written in C, thus you should try this:

ByVal pszDocPublished As String
pszDocPublished = string(200, " ") & chr(0)

and then call the function

CHeers


0
 
LVL 6

Expert Comment

by:Nitin Sontakke
ID: 7029903
angellll is right. It does look like a C library function. I would suggest a minor change in his code.

Dim pszDocPublished As String
pszDocPublished = String(200, Chr(0))

He was initializing it with space and then terminating with Null. I would recommend to fill it totally with Null characters.

0
 
LVL 2

Expert Comment

by:ventond
ID: 7030871
Actually ByVal is okay in this instance, because it is actually a Pointer. And the Pointer doesn't change, just what it points to changes. Now how to get VB to use that as a pointer and not a long variable.
0
 
LVL 2

Expert Comment

by:ventond
ID: 7030873
I may have misread the declare, so feel free to ignore my previous comment.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

786 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