Real Software Forums

Basic Math
Page 1 of 1

Author:  alloyd21 [ Wed May 18, 2011 9:34 pm ]
Post subject:  Basic Math


I've just started with RealBasic and was wondering how I would go about making a simple calculator where you input 3 different numerical imputs, the program then does the calculations based on this formula : 10xAx(b-c)=Answer (where a,b,c are the inputs.) I have previous experience with, if that helps.

Here is a link to an image of the Window/form:

Thanks :)

Author:  timhare [ Thu May 19, 2011 2:03 am ]
Post subject:  Re: Basic Math

The first thing you need is to get the values from the textfields as numbers. The value typed into the field is available as a string in TextField.Text. You can convert a string to a number with CDbl(). So your code will look something like
dim a, b, c, answer as double
a = CDbl(TextField1.Text)
b = CDbl(TextField2.Text)
c = CDbl(TextField3.Text)
answer = 10 * a * (b - c)

Now you need to display the answer somewhere. "Displaying" anything requires a string. You can convert a number to a string with Format().
TextField4.Text = Format(answer, "#")

Refer to the documentation for additional details.

Author:  alloyd21 [ Fri May 20, 2011 1:35 am ]
Post subject:  Re: Basic Math

Thank you sooooo much

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group