What-ho,
there's a lot of people doing calculators atm...is it a school project or something?
Still - here's how I'd do your way of doing things (which is, er, a unique way of implementing a calculator):
Set up a form with the following on it:
3 x TextBox controls: txtArgOne txtArgTwo txtResult
1 x ListBox control: lstActions
1 x CommandButton: cmdCalculate
Now put the following in your form code:
Private Sub cmdCalculate_Click()
Select Case Me.lstActions.List(Me.lstActions.ListIndex)
Case "Add"
Me.txtResult.Text = Val(Me.txtArgOne.Text) + Val(Me.txtArgTwo.Text)
Case "Subtract"
Me.txtResult.Text = Val(Me.txtArgOne.Text) - Val(Me.txtArgTwo.Text)
Case "Multiply"
Me.txtResult.Text = Val(Me.txtArgOne.Text) * Val(Me.txtArgTwo.Text)
Case "Divide"
Me.txtResult.Text = Val(Me.txtArgOne.Text) / Val(Me.txtArgTwo.Text)
Case "Modulus"
Me.txtResult.Text = Val(Me.txtArgOne.Text) Mod Val(Me.txtArgTwo.Text)
End Select
End Sub
Private Sub Form_Load()
Me.lstActions.AddItem "Add"
Me.lstActions.AddItem "Subtract"
Me.lstActions.AddItem "Multiply"
Me.lstActions.AddItem "Divide"
Me.lstActions.AddItem "Modulus"
End Sub
Bear in mind that there's no error checking here. so if yu put words in instead of numbers, it'll probably go wrong and kill everyone...well, probably not, but you never know.
This is a
"simple" way of doing things - que postings of
"clever" ways
Cheerio,
Paul [sig][/sig]