vbdpss.hlp (Table of Contents; Topic list)
Article Q27325
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Example Passing Near Numeric Variables between Basic and C - Q27325
 
 The two programs shown below demonstrate how numeric variables can be
 passed from compiled Basic to Microsoft C by near reference.
 
 This information applies to the Standard and Professional Editions of
 Microsoft Visual Basic version 1.0 for MS-DOS and to Microsoft C
 Compiler version 7.0.
 
 To compile this example in Visual Basic for MS-DOS, execute the
 following commands:
 
    BC BMODULE.BAS;
    CL -c -AM CMODULE.C
    LINK BMODULE.OBJ CMODULE.OBJ;
 
 Basic Program
 -------------
 
 DECLARE SUB NumericNear CDECL (a%,b&,c!,d#)
 
 a% = 32767
 b& = 32769
 c! = 123.312
 d# = 129381.333#
 
 CLS
 CALL NumericNear(a%, b&, c!, d#)
 LOCATE 5, 1
 END
 
 C Routine
 ---------
 
 #include <stdio.h>
 
 void NumericNear(int *a, long *b, float *c, double *d) {
    printf("INTEGER %d\", *a);
    printf("LONG    %ld\", *b);
    printf("FLOAT   %f\", *c);
    printf("DOUBLE  %lf\", *d);
 }
 
 Output
 ------
 
 INTEGER 32767
 LONG    32769
 FLOAT   123.311996
 DOUBLE  129381.333000