Begginer needs help

Hi i’m in a programming a class and i’m doing an assignment i’ve gotten
it to work but one of the entries is messed up it takes the place of a
diffrent one

Here’s the code

require ‘gtk2’

window =
window.border_width = 10
window.title = “Future Value Investment Calculator”

convertButton =“Convert”)
closeButton =“Close”)
oink =“piggybank.gif”, 150, 200))
promptLabel =“Enter amount invested in U.S Dollars:”)
tempEntry =
promptLabel2 =“Enter Rate of return as a decimal(e.g.
enter 8% as .08):”)
tempEntry2 =
promptLabel3 =“Enter number of years the money will be
tempEntry3 =
resultLabel ="")

vbox1 =, 0)
hbox1 =, 0)
hbox2 =, 0)

hbox1.pack_start(convertButton, true, false)
hbox1.pack_start(closeButton, true, false)

vbox1.pack_start(promptLabel, true, true)
vbox1.pack_start(tempEntry, true, true)
vbox1.pack_start(promptLabel2, true, true)
vbox1.pack_start(tempEntry2, true, true)
vbox1.pack_start(promptLabel3, true, true)
vbox1.pack_start(tempEntry3, true, true)
vbox1.pack_start(resultLabel, true, true)
vbox1.pack_start(hbox1, true, true)

hbox2.pack_start(vbox1, true, true)
hbox2.pack_start(oink, true, true)


convertButton.signal_connect(“clicked”) {

dollars = tempEntry.text.to_f

rate = tempEntry.text.to_f

time = tempEntry.text.to_i

fv = dollars*(1+rate)**time

output= " In " + time.to_s + " years your investment will be worth " +

resultLabel.set_label( output )

closeButton.signal_connect(“clicked”) {

window.signal_connect(“destroy”) {


if u could help i would really appreciate it


On 26.09.2010 02:36, Jake Alucard wrote:

convertButton.signal_connect(“clicked”) {

dollars = tempEntry.text.to_f

rate = tempEntry.text.to_f

time = tempEntry.text.to_i

Look carefully which gtk widgets you access. You always access
“tempEntry” but you named the others “tempEntry2” and “tempEntry3”.

Lesson you should learn here: use distinctive naming :wink:

  • Markus

thank you so much :smiley:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs