Solved

How to get the returned value ?

Posted on 2002-05-23
5
120 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now