New topic: 

if statement and popup box trouble

<http://forums.realsoftware.com/viewtopic.php?t=46325>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        shad0wman          Post subject: if statement and popup box 
troublePosted: Sun Dec 23, 2012 12:30 am                         
Joined: Sun Dec 23, 2012 12:23 am
Posts: 1                basically i have a calculator for building houses and 
rooms. for the electrical section i have a popup menu to choose 120v or 240v, 
and in this calculate button i want different values for output based on which 
selection

dim l,w,answer,min,opt,max,minv1,minv2,optv1,optv2,maxv1,maxv2 as double
l = CDbl (lengthfield.text)
w = CDbl (widthfield.text)
answer = l * w
min = answer * 25
opt = answer * 40
max = answer * 60
minv1 = 120 / min
minv2 = 240 / min
optv1 = 120 / opt
optv2 = 240 / opt
maxv1 = 120 / max
maxv2 = 240 / max

if voltsmenu.Text = "120" then
  
  answerlabel.text = "Your room is " + Format(answer, "#") + " sqft, please 
review the 3 levels of recommendation below suited for your grow room."
  minimumwatt.text = "The minimum recommended lighting for your area is " + 
Format(min, "#") + " watts." + " This setup will require " + Format(minv1, "#") 
+ " amps to be available at all times for safest operation."
  optimumwatt.text = "The optimum recommended lighting for your area is " + 
Format(opt, "#") + " watts."+ " This setup will require " + Format(optv1, "#") 
+ " amps to be available at all times for safest operation."
  maxwatt.text =  "The maximum recommended lighting for your area is " + 
Format(max, "#") + " watts."+ " This setup will require " + Format(maxv1, "#") 
+ " amps to be available at all times for safest operation."
  
end if

if voltsmenu.text = "240" then
  
  answerlabel.text = "Your room is " + Format(answer, "#") + " sqft, please 
review the 3 levels of recommendation below suited for your grow room."
  minimumwatt.text = "The minimum recommended lighting for your area is " + 
Format(min, "#") + " watts."+ " This setup will require " + Format(minv2, "#") 
+ " amps to be available at all times for safest operation."
  optimumwatt.text = "The optimum recommended lighting for your area is " + 
Format(opt, "#") + " watts."+ " This setup will require " + Format(optv2, "#") 
+ " amps to be available at all times for safest operation."
  maxwatt.text =  "The maximum recommended lighting for your area is " + 
Format(max, "#") + " watts."+ " This setup will require " + Format(maxv2, "#") 
+ " amps to be available at all times for safest operation."
  
end if


no errors or anything just when it calculates, it is always 0 for the the v1s 
and v2s, im guessing because im taking previous variables that had to be 
calculated beforehand, im stuck ><   
                             Top                charonn0          Post subject: 
Re: if statement and popup box troublePosted: Sun Dec 23, 2012 1:26 am          
                       
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1049
Location: San Francisco, CA, USA                Add more #'s to your Format 
statements. Each # corresponds to only 1 digit place. If there are fewer #'s 
than digit places in the number being formatted, the number is rounded up or 
down to the nearest integer. You must also explicitly specify the location of 
the decimal point, otherwise the decimal point is assumed to be after the 
rightmost number.

e.g.

Dim s As String
Dim d As Double = 0.1
s = Format(d, "#")
's = "0"

Dim s As String
Dim d As Double = 0.5
s = Format(d, "#")
's = "1"

Dim s As String
Dim d As Double = 0.5
s = Format(d, "##")
's = "1"

Dim s As String
Dim d As Double = 0.5
s = Format(d, "#.#")
's = "0.5"
      
_________________
Boredom Software  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to