Posts: 8
Threads: 2
Joined: Oct 2003
Lets say the i have the code:
INPUT "Enter a 2-digit number";number
How could i take the variable "number" and break it apart into 2 serperate variables?
For example id the user enters number = 34
How could i make number1 = 3
and number2 = 4
?
Posts: 3,368
Threads: 195
Joined: Jan 2003
The answer is:
Exactly how you would do it with mathematics.
There are several such approaches.
The easiest, conceptually, is to say (given x=input, A=tens digit, and B=ones digit):
b = x MOD 10
a = x - b
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 8
Threads: 2
Joined: Oct 2003
BTW, how do i combine 2 variables, for example:
x=1
y=5
How do i make is print 15 instead of 1 5?
Posts: 6,419
Threads: 74
Joined: Mar 2002
Posts: 3,368
Threads: 195
Joined: Jan 2003
Hm... well... in that case . . .
Why not just say:
Code:
INPUT "gimme a number", n$
x% = VAL(MID$(n$, 1, 1 ))
y% = VAL(MID$(n$, 2, 1))
:lol:
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 3,368
Threads: 195
Joined: Jan 2003
True...
You can validate that it is a number by checking the ASC() value of each digit...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
even so then youd have to use a sloppy goto loopif they aren't, when you could just let qbasic give a 'redo from start' error for you. i dunno let's make peace brotha lol 8)
Posts: 3,343
Threads: 83
Joined: Mar 2003
Why do you have to make a goto loop?
Nothing needs a goto loop