Solved

How to get the returned value ?

Posted on 2002-05-23
5
126 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
[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
  • 2
  • 2
5 Comments
 
LVL 9

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 143

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 9

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

623 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