Solved

How to get the returned value ?

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

762 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

25 Experts available now in Live!

Get 1:1 Help Now