ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DECLARE Statement (Non-Basic Procedures) Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the DECLARE statement to use a C function in a Basic
' program. The Basic program calls the function addone, which uses C argument
' passing and takes a single integer argument passed by value.
 
' Note: To run this program, you must compile the C function separately
' and place it in a Quick library or link it to the Visual Basic program.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 DEFINT A-Z
 DECLARE FUNCTION addone CDECL (BYVAL n AS INTEGER)
 CLS                 ' Clear the screen
 INPUT x
 y = addone(x)
 PRINT "x and y are "; x; y
 END
 
' /* C function addone. Returns one more than the value of its argument. */
'
' int far addone(int n)
' {
'    return(n+1);
' }