Microsoft KB Archive/27291

= Example Passing Numeric Variables from Basic to C by Value =

Article ID: 27291

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q27291



SUMMARY
The program below demonstrates how to pass numeric values from compiled Basic to Microsoft C by VALUE.



MORE INFORMATION
For more information about passing other types of parameters between Basic and C, and a list of which Basic and C versions are compatible with each other, query in the Microsoft Knowledge Base using the following word:

BAS2C

Code Example
REM ===== 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#) END

/* ===== C ROUTINE ===== */ /* The variables are put into structs for memory alignment. */ struct struct_int{ int x;  }; struct struct_long{ long x;  }; struct struct_float{ float x;  }; struct struct_double{ double x;  }; void NumericValue(a, b, c, d)  struct struct_int a;   struct struct_long b;   struct struct_float c;   struct struct_double d;   { printf(&quot;INTEGER %d        \n&quot;,a.x); printf(&quot;LONG    %ld        \n&quot;,b.x); printf(&quot;FLOAT   %f        \n&quot;,c.x); printf(&quot;DOUBLE  %lf        \n&quot;,d.x); } ===== OUTPUT =====
 * 1) include 

INTEGER 32767 LONG    32769 FLOAT   123.311996 DOUBLE  129381.333000

Additional query words: QuickBas BasicCom

Keywords: KB27291

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.