Quote:

>Subject: Numbers in Qbasic

>Date: Fri, 24 May 1996 01:47:15 GMT

To answer the second question first:

Quote:

>Also, is there a way to get Qbasic to print two seperate variables

>without a space between them? When I put Print d; a the output would

>be: d a. I want it to be da with no space. D and A are numbers.

QBasic puts a space in front of POSITIVE numbers, in negative numbers the

space is replaced by the minus sign. You need to convert the number to

a string and then trim it ie:

PRINT LTRIM$(VAL(d));LTRIM$(VAL(a))

Which leads us to the answer to the first question:

Quote:

>Is there any way of putting extra zeros in front of a number in

>Qbasic? For example: the number 2.57664655445, is there a way to turn

>it into 002.57664655445 without making a string? It has to make the

>integer part fully 3 digits, keeping the decimal part. So with 25.545,

>it would turn into 025.545. And any numbers that are already three

>digits, they stay the same.

Once more, you need to convert to a string and manipulate it appropriately

IntegersWanted=3

MyNum= 25.545

REM Get the Number as a string

Temp$ = LTRIM$(VAL(MyNum))

REM Find how big the integer part is

Integersize=INSTR(Temp$,".")

REM Make enough 0's

LeadingZero$=""

IF Integersize < Integerswanted THEN

LeadingZero$ = STRING$("0",IntegersWanted - IntegerLength)

END IF

REM Put them together

MyNum$ = LeadingZero$ + Temp$

Cheers,

--

Disclaimer?? The opinions of the writer ARE the opinions of Lexacorp!!

----------------------------------------------------------------------

LEXACORP Pty Ltd, Brisbane, Qld Australia

Dataflex/MSAccess/Basic System Development