How to input numbers

Just starting out? Need help? Post your questions and find answers here.
hessu
User
User
Posts: 25
Joined: Fri Nov 20, 2015 6:30 am

How to input numbers

Post by hessu »

I want to write a simpel mathematic program. But I don't know how to Input numbers.
open console()
a$=input()
b$=input()
a=Val(a$)
b=Val(b$)

if I input a$ as 1.5 and b$ as 2

debug a *b

aswer will be 2

min question is : How I can input numeric values

I've programmed in Liberty Basic and no problem with this

:oops: :oops:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: How to input numbers

Post by Kwai chang caine »

Hello Hessu, and welcome in the amazing word of PB :D

Because when you use float number you must convert to float too

Code: Select all

OpenConsole()
a$=Input()
b$=Input()
a.f=ValF(a$)
b.f=ValF(b$)
Debug a*b
Furthermore, when you put code, it's better to use

Code: Select all

 /code][/color][/b] tag  :wink:
ImageThe happiness is a road...
Not a destination
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: How to input numbers

Post by Mindphazer »

Use ValF() or ValD() instead of Val()
Val() is used for integers or Quads only
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
hessu
User
User
Posts: 25
Joined: Fri Nov 20, 2015 6:30 am

Re: How to input numbers

Post by hessu »

Thank you very much

:lol: :P
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: How to input numbers

Post by Kwai chang caine »

For one time, the question is not too complicated, for i can help :wink:
Usually, it's or too hard...or too late :mrgreen:

Too much MASTERS of programming haunt this forum, there is surely a nest hidden somewhere :shock: :lol: :lol:

Again welcome in the powerfull word of PB and his champion team 8)

Image
ImageThe happiness is a road...
Not a destination
Al_the_dutch
User
User
Posts: 70
Joined: Mon Nov 11, 2013 11:07 am
Location: Portugal

Re: How to input numbers

Post by Al_the_dutch »

Perhaps this might be usefull too.
http://www.purebasic.fr/english/viewtop ... 13&t=66325

Succes
Al
Post Reply