vbdpss.hlp (Table of Contents; Topic list)
Article Q27291
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Example Passing Numeric Variables from Basic to C by Value - Q27291
 
 The program below demonstrates how to pass numeric values from
 Basic to Microsoft C by value.
 
 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 NumericValue CDECL (_
             BYVAL p1 AS INTEGER,_
             BYVAL p2 AS LONG,_
             BYVAL p3 AS SINGLE,_
             BYVAL p4 AS DOUBLE)
 
 a% = 32767
 b& = 32769
 c! = 123.312
 d# = 129381.333#
 
 CLS
 CALL NumericValue(a%, b&, c!, d#)
 LOCATE 5, 1
 END
 
 C Routine
 ---------
 
 #include <stdio.h>
 
 void NumericValue(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