PDA

View Full Version : Help Creating A Calculator



Xtreme11
03-11-2011, 12:05 AM
Dim dblOperand1 As Double
Dim dblOperand2 As Double
Dim dblResult As Double

If dblOperand2 = 0 Then
MsgBox "The answer is undefined", vbCritical, "Error"
cmdClear_Click
Else: dblResult = dblOperand2 / 0
mstrPendingClear = "Yes"
txtCurrentValue.Value = dblResult
End If
updateTextboxes
End Sub

Is there something wrong in this procedure because I am able to use a provided "Checker" to check if I have certain steps written the right way. However, for this step I am getting "Last statement 1/0=RUNTIME ERROR!
This is for the square root button in the calculator.
Any help will be appreciated. Thanks

Abhijeet
03-11-2011, 12:26 AM
I had created a calculator in excel using VBA..if u want i can share with u..maybe it can be of some assistance..

GTO
03-11-2011, 12:26 AM
dblOperand2 / 0

I believe you are attempting to divide by zero, which ain't gonna make excel happy...

Xtreme11
03-11-2011, 12:35 AM
Abhijeet that would be very helpful. GTO I had a feeling about that but how can I change that to make it work?

Xtreme11
03-11-2011, 12:39 AM
I have to implement an error check in the divide button and that part that I wrote is for calculating divison by 0 errors

Abhijeet
03-11-2011, 12:42 PM
@Xtreme11: plz let me know ur e-mail

Aussiebear
03-11-2011, 02:12 PM
I had created a calculator in excel using VBA..if u want i can share with u..maybe it can be of some assistance..
Since the purpose of this forum is to enable public discussion of threads raised, let us dispense with the requests for private email addresses. Others who visit or participate in the discussions may also be interested in where this thread is headed.