Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   What's wrong with this code? (https://www.askmehelpdesk.com/showthread.php?t=269100)

  • Oct 13, 2008, 09:58 PM
    askforhelp22
    What's wrong with this code?
    Dim number1 As Integer
    Dim number2 As Integer
    Dim result As Integer

    number1 = (4 * 6 ^ 4) / (10 Mod 4 - 2)
    number2 = (16 \ 3) ^ 2 * 6 + 1
    result = number1 - number2
  • Oct 13, 2008, 10:13 PM
    askforhelp22

    Can someone answer this please?
  • Oct 23, 2008, 02:14 PM
    devonknows
    Quote:

    Originally Posted by askforhelp22 View Post
    Dim number1 As Integer
    Dim number2 As Integer
    Dim result As Integer

    number1 = (4 * 6 ^ 4) / (10 Mod 4 - 2)
    number2 = (16 \ 3) ^ 2 * 6 + 1
    result = number1 - number2

    Have you tried

    number1 = CInt(4 * 6 ^ 4) / CInt(10 Mod 4) - 2

    As the division by zero comes in when you insert the -2 into the brackets.

    I used this code

    Code:

    number1 = CInt(4 * 6 ^ 4) / CInt(10 Mod 4) - 2
    number2 = (16 \ 3) ^ 2 * 6 + 1
    result = number1 - number2

    MsgBox result

    and got an answer of 2439. Unsure if that is the answer you are looking for.

    Devon

  • All times are GMT -7. The time now is 08:53 PM.