How can I display a floating variable (with decimales?):
zahl.f = Val(InputRequester("Input number: ", "Input number: ", ""))
MessageRequester("The number is: ", Str(zahl))
If I input e.g. 3.14 (or 3,14) the result is 3. But it should be 3.14 (or 3.14). Why does PB returns an integer?
Thanks, Roland.
			
			
									
									
						Variable: float
Welcome rolstra 
ValF and StrF are your friends here.
			
			
									
									ValF and StrF are your friends here.
Code: Select all
zahl.f = ValF(InputRequester("Input number: ", "Input number: ", "")) 
MessageRequester("The number is: ", StrF(zahl,2)) 
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
						PB 5.21 LTS (x86) - Windows 8.1
- Kaeru Gaman
 - Addict

 - Posts: 4826
 - Joined: Sun Mar 19, 2006 1:57 pm
 - Location: Germany
 
welcome.
to keep Val() and Str() faster, it has no check for integer/float.
thus there are different functions for each type.
you normally know the type of a variable you pass to a function.
other languages have only one function with a typecheck.
more conveniant to the programmer, but less performant.
			
			
									
									to keep Val() and Str() faster, it has no check for integer/float.
thus there are different functions for each type.
you normally know the type of a variable you pass to a function.
other languages have only one function with a typecheck.
more conveniant to the programmer, but less performant.
oh... and have a nice day.
						
