Consulting

Results 1 to 7 of 7

Thread: Help Creating A Calculator

  1. #1
    VBAX Newbie
    Joined
    Mar 2011
    Posts
    3
    Location

    Help Creating A Calculator

    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

  2. #2
    I had created a calculator in excel using VBA..if u want i can share with u..maybe it can be of some assistance..

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    dblOperand2 / 0

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

  4. #4
    VBAX Newbie
    Joined
    Mar 2011
    Posts
    3
    Location
    Abhijeet that would be very helpful. GTO I had a feeling about that but how can I change that to make it work?

  5. #5
    VBAX Newbie
    Joined
    Mar 2011
    Posts
    3
    Location
    I have to implement an error check in the divide button and that part that I wrote is for calculating divison by 0 errors

  6. #6
    @Xtreme11: plz let me know ur e-mail

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Quote Originally Posted by Abhijeet
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •