ERASING NEG FIGURES

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
URSULE

ERASING NEG FIGURES

Post by URSULE »

As a result of calculation I get a serie which has positive and negative figures.I would like to eliminate for a PRINT of thes values, all the negatives figures (I don't need them).ABS gives the figures without sign and is not the answer. How can I do?
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Code: Select all

If Value >= 0 Then Print Value
If using an array:

Code: Select all

For a = 0 To arrLen
 If Arr(a) >= 0 Then Print Arr(a)
Next
I have left this dump.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ok, Ummm here we go:

It easy

Do this:

Code: Select all

arrayname2i = 0
FOR i = LBOUND(arrayname) TO UBOUND(arrayname)
   IF i >= 0 THEN arrayname2i = arrayname2i + 1 : arrayname2(arrayname2i) = arrayname(i)
NEXT i
Or (my pref):

Code: Select all

'when you want to PRINT it
FOR i = LBOUND(arrayname) TO UBOUND(arrayname)
   IF i >= 0 THEN PRINT arrayname(i)
NEXT i
The first one takes a series of values from arrayname and transfers only the ones that are 0 or postitive to arrayname2. Just have arrayname2 have the same range as arrayname. And use arrayname2 for now on or transfer the vals back to arrayname AFTER you clear it first.

The second one PRINTs out the values in arrayname only those that are 0 or positive. This way I preferr. :wink:

Well if that didn't answer you question then please explain more or provide source please...

Hey Rattrap I beat you on this one HA! :D
"But...It was so beutifully done"
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Darn Z!re posted before me...She wasn't here when I looked at it though...Sorry Z!re for just saying what you said in more words....heh...
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:wink: He posted a few soconds b4 you, oh well,.. I'm glad you 2 it first, I'd had to ponder on this one for a min,. :D ,. now I no have to, heh heh,. :wink:

I'm still confused, Z!re, you a boy or girl? I saw the comment, I thought you were commenting that QB Gals EM had MID$(email,,4) = "Lord" in it,..

Doesn't matter either way, I'm just screwed up, and liked to be set strait with a solid answer. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ya Z!re lets set this strait you a guy or girl?
"But...It was so beutifully done"
Post Reply