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. */ #include <stdio.h> 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("INTEGER %d \n",a.x); printf("LONG %ld \n",b.x); printf("FLOAT %f \n",c.x); printf("DOUBLE %lf \n",d.x); }
===== OUTPUT ===== INTEGER 32767 LONG 32769 FLOAT 123.311996 DOUBLE 129381.333000
Additional query words: QuickBas BasicCom
Keywords: KB27291