Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weight in Space input problem
#1
heres my code so far, my input isnt allowing letters only numbers

Code:
cls
input "Input Friends Name";nameA
input "Input Friends Weight";weight1

'planets gravity
mercury = .27
venus = .85
earth = 1
moon = .16
mars =.18
jupiter = 2.64
saturn = 1.17
uranus = .92
neptune = 1.12
when i input a friends name as a test it wont take it however it will allow the numbers.
ife is Short Lets pick on it.
Reply
#2
[syntax="qbasic"]cls
input "Input Friends Name";nameA$[/syntax]

there must be the '$' after the varible to say it is a string

Oz~
Reply
#3
Or, at the start:
[syntax="qbasic"]dim nameA as string[/syntax]
/post]
Reply
#4
[syntax="QBASIC"]INPUT "Your weight? ", weight
PRINT "Your weight in space is"; weight * 0[/syntax]

Shhhhhhhhhhhhhhhhhh
Sorry had to :roll:
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#5
Quote:[syntax="QBASIC"]INPUT "Your weight? ", weight
PRINT "Your weight in space is"; weight * 0[/syntax]

Shhhhhhhhhhhhhhhhhh
Sorry had to :roll:

Not really. It depends upon your proximity to a source of gravity =P.

rhoward: Its a good practice to declare the variables before you start off using them. If you dont want to declare them then you can add a suffix to indicate their type. For eg. Strings - $, Integer - %, Single precision - !, Double Precision - &

Quote:cls
input "Input Friends Name", nameA$
input "Input Friends Weight", weight1!

'planets gravity
mercury! = .27
venus! = .85
earth! = 1
moon! = .16
mars! =.18
jupiter! = 2.64
saturn! = 1.17
uranus! = .92
neptune! = 1.12
Reply
#6
Default type in QB is single... thus ! is not needed unless you use defint, deflng, defstr
Reply
#7
Code:
cls
input "Input Friends Name";nameA
input "Input Friends Weight";weight1

'planets gravity
mercury = .27
venus = .85
earth = 1
moon = .16
mars =.18
jupiter = 2.64
saturn = 1.17
uranus = .92
neptune = 1.12

Cry What about Pluto? Cry
Reply
#8
Nobody cares about pluto. "Weightlessness" has nothing to do with being far away from earth. "g" is still 8.something in orbit, it's the centripital force of the craft in orbit countering gravity that makes you weightless.

So long as there is other matter in the universe, you can't really be weightless.
Reply
#9
Quote:Nobody cares about pluto.

Oh, should I ask this Nobody guy then?

Where can I get in touch with Nobody?

Jofers, please reply as soon as possible!

Thanks,

Nemesis
Reply
#10
I thought you were Mr.Nobody! :rotfl:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)