943,547 Members | Top Members by Rank

Ad:
Mar 9th, 2009
0

What is "Private Declare Function ....."?

Expand Post »
visualbasic Syntax (Toggle Plain Text)
  1. Private Declare Function Function_Name Lib "user32" () As Datatype

I've found such lines used in many VB6 projects and tutorials.
What is it? What actually is this used for? Are there more such function? How to find out more such function/properties?
A detail explanation will be helpful and highly appreciated.
Thank you.

(Is it calling read-only or some library functions or properties?)
Last edited by RahulV; Mar 9th, 2009 at 4:06 pm.
Similar Threads
Reputation Points: 26
Solved Threads: 0
Junior Poster in Training
RahulV is offline Offline
92 posts
since Jun 2007
Mar 9th, 2009
0

Re: What is "Private Declare Function ....."?

Click to Expand / Collapse  Quote originally posted by RahulV ...
visualbasic Syntax (Toggle Plain Text)
  1. Private Declare Function Function_Name Lib "user32" () As Datatype

I've found such lines used in many VB6 projects and tutorials.
What is it? What actually is this used for? Are there more such function? How to find out more such function/properties?
A detail explanation will be helpful and highly appreciated.
Thank you.

(Is it calling read-only or some library functions or properties?)
It's declaring a function from an external library to be used in the current class or module. Private tells the compiler (or interpreter) that you want the sub procedure or function to be defined for the current class or module only. That is to say, other classes or modules in the project may not access it. Declare states to the interpreter that the sub procedure or function is defined later in the class or module or in an external class or module. Function, of course is a function. That is to say, a procedure that returns a value. The function name is self explanitory. Lib states where the function is defined, which is seen in quotes followed by the term. In this case, it would be in "user32." and the rest is all standard syntax for a function declaration.

You can get references for any external libraries online if you use the right search terms. Here is a refererence for user32.dll as used in your statement. Another popular library to reference is shell32.dll.
Last edited by SlyMaelstrom; Mar 9th, 2009 at 5:56 pm.
Reputation Points: 15
Solved Threads: 2
Newbie Poster
SlyMaelstrom is offline Offline
21 posts
since Oct 2005
Mar 10th, 2009
0

Re: What is "Private Declare Function ....."?

Otherwise known as API. Application Programming Interface. If you have VB 6.0 SP?, then you can access the API view via the vb interface or design environment buy the menu item Add-Ins...

Click on Add-Ins and if you do not see an entry in the sub menu that says API Viewer then goto Add-In Manager.
It takes a moment for it to come up but look for the entry in the list that says VB 6 API Viewer.
Highlight it and then check the checkbox that says Loaded/Unloaded. (My option is to also check the Load On Startup)
Click OK.

Now, go back to the menu item, Add-Ins, and you should now see an entry for API Viewer in the sub menu.
Select it.

In a moment another dialog appears.
Goto File>Load Text File.
The Common dialog open appears and you should see three files listed.
Select WIN32API.TXT
In a moment it should load with API declarations, constants, and types that you can use to extend the functionality of your program.

Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: checking input data using checkinput() function
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to di this....





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC