Solved

How to get the returned value ?

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

738 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