Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input 2 digit numbers
#41
Could you give me an example of when you would want to use the "val()" function with a numeric string? Wouldn't this be completely pointless?
Reply
#42
Quote:Could you give me an example of when you would want to use the "val()" function with a numeric string? Wouldn't this be completely pointless?

It's often wise to get user-input as a string, and then parse that string to numbers/symbols/text/whatever.
Reply
#43
Without local echo:
Code:
1 PRINT "Enter a two digit number: ";
2 k$ = INPUT$(1)
3 IF k$ < "0" OR k$ > "9" THEN GOTO 2 ELSE Num% = 10 * VAL(k$)
4 k$ = INPUT$(1)
5 IF k$ < "0" OR k$ > "9" THEN GOTO 4 ELSE Num% = Num% + VAL(k$)

With local echo:
Code:
1 PRINT "Enter a two digit number: ";
2 k$ = INPUT$(1)
3 IF k$ < "0" OR k$ > "9" THEN GOTO 2 ELSE Num% = 10 * VAL(k$): PRINT k$;
4 k$ = INPUT$(1)
5 IF k$ < "0" OR k$ > "9" THEN GOTO 4 ELSE Num% = Num% + VAL(k$): PRINT k$

*peace*

Meg.
Reply
#44
Trust Meg to come up with a nice clean approach.
Nice work, Meg.
Better late than never. :wink:
*****
Reply
#45
some dude: never send a lady to do a mans job

me: hell no *smack*

meg you rock Smile
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)