QUOTE(mgeraght @ 10 Feb, 2007 - 04:05 PM)

Hi, I have been assigned (for a class) to make a calculator. It has to have add, subtr, multiply, divide and Square root. I have gotten all of these to work but when I try to use my square root button I get an error because i am only using one of the two input boxes.
I am at a loss. The design of my calculator has two text boxes for number input, a combo box for operations and a label box for the answer. I will give the script and keep my fingers crossed that one of you knows what is going wrong.
Private Sub cmdEqual_Click()
Dim Box1 As Single
Box1 = txtDisplay.Text
Dim Box2 As Single
Box2 = txtDisplay2.Text
Dim sngComputes As Single
Select Case cboFunctions.Text
Case "Add"
sngComputes = Box1 + Box2
Case "Subtract"
sngComputes = Box1 - Box2
Case "Multiply"
sngComputes = Box1 * Box2
Case "Divide"
sngComputes = Box1 / Box2
Case "SquareRoot"
sngComputes = (txtDisplay.Text ^ (1 / 2))
If Box1 < 1 Then
MsgBox "Cannot have a negative number"
End If
End Select
Dim Solution As Single
Solution = sngComputes
lblAnswer.Caption = Solution
End Sub
The error could be that you are not assinging any information to box2. You might want to place an if statement so that if box2 is not used it knows that you are going to be performing a square root.