Results 1 to 32 of 32

Thread: Thanks re:textbox but....new problem!

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    10
    Ok thanks for all the help so far, got my txtboxes and calculations all working just like they should....except...one calculation is giving a 'divide by zero' error.
    Whats the best way to deal with this? Should I just limit the values available for this txtbox so that it can't happen? Or is there another way to make the program either ignore this or return a 'please enter another value' msgbox....or something else????

    Thanks,
    Scott
    Trying to teach myself visual basic

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    a division by zero is IMPOSIBLE so vb give you an error..
    place that....




    Sub ...............
    On error goto error1
    'calculation operation here
    exit sub
    error1:
    msgbox "Sorry, an error occur in the proccess .." _
    & vbcrlf & "Impossible opération ?"
    end sub

  3. #3
    Member
    Join Date
    Jul 2000
    Location
    BFE in Oregon
    Posts
    33

    Cool

    I'm still not too sure why processor manufacturers can't figure this one out...If you divide by zero obviously the answer is going to be zero.
    0 * anything = 0
    anything * 0 = 0
    0 / anything = 0
    anything / 0 = 0

    We learned this in math class in first grade (if not kindergarten). Why is such a simple principle ignored when it comes to technology?
    And another thing that really p*sses me off is the fact that the operating systems over the years haven't trapped this annoying error. All you have to do is trap the error and change the value to zero! It's really that damn simple!
    Yeah, it's probably not the result that your function or application wants but it is the correct formula.
    To contrast this why is there no multiply by zero error? It uses the same function...

    Just another of the 'acceptable bugs' in processor development.
    Glacius Cool
    Concept Designer
    VB5sp4,VC++6sp3

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    10
    Ok, so how do I make a simple error trap that will tell the program to set anything divided by 0 to = 0?

    thanks,
    Scott
    Trying to teach myself visual basic

  5. #5
    Member
    Join Date
    May 2000
    Location
    Sweden
    Posts
    50

    Wink

    Sub...
    on error goto Errorhandler
    'your code goes here
    exit sub
    Errorhandler:
    If Err.Number=11 then
    Result=0
    resume Next
    Else
    Msgbox Err.Description
    End If
    End Sub
    Wolf

    VB6 SP5

  6. #6
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    Originally posted by Glacius Cool
    I'm still not too sure why processor manufacturers can't figure this one out...If you divide by zero obviously the answer is going to be zero.
    Actually you are wrong. You cannot divide by 0! The answer is undefined, not zero!
    (I not sure which school you went to.)

    You can multiply by 0, but not divide.
    Donald Sy - VB (ab)user

  7. #7
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    If you divide anything by zero you get infinity.

    It's rather hard to display infinity, so VB just vomits.

    If this is going to turn into an argument about zeros and infinity then lets mosey on over to the Chit Chat forum and redefine the universe.
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  8. #8
    Guest
    You CAN'T divide by zero.

    Look at it this way.
    1 / 0.1 = 10
    1 / 0.01 = 100
    1 / 0.001 = 1000
    1 / 0.0000000001 = 10000000000

    If you keep calculating you'll get an infinite number if you divide by zero, you define it like so:
    -
    Lim(a / x) = Infinity
    x->0
    -

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by Glacius Cool
    I'm still not too sure why processor manufacturers can't figure this one out...If you divide by zero obviously the answer is going to be zero.
    0 * anything = 0
    anything * 0 = 0
    0 / anything = 0
    anything / 0 = 0

    We learned this in math class in first grade (if not kindergarten). Why is such a simple principle ignored when it comes to technology?
    I'm with you as far as
    0 / anything = 0
    because
    0 * anything = 0
    but if
    anything / 0 = 0
    then
    0 * 0 = anything
    and that is incorrect isn't it...???
    5 / 0 = 0
    would give that
    0 * 0 = 5

  10. #10
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    Originally posted by Arbiter
    If you divide anything by zero you get infinity.

    It's rather hard to display infinity, so VB just vomits.

    If this is going to turn into an argument about zeros and infinity then lets mosey on over to the Chit Chat forum and redefine the universe.
    I think we can avoid the chit chat; it is not infinity. It is undefined. I should know , I majored in math - long before computers or calculators and when we still had to
    use sliderules. Most of the posters on this board grew up
    using calculators.

    See this link http://ubmail.ubalt.edu/~harsham/zer...TM#rsimpalgcom

    [Edited by dsy5 on 09-10-2000 at 05:13 PM]
    Donald Sy - VB (ab)user

  11. #11
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    why not just check the value of the divisor before you do the division and if it is zero then exit the sub (with an explanation if you want)
    Msgbox "Sorry, division by 0 is not permissible"

    End of story.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  12. #12
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Talking

    Well everyone to divide anything by zero is imposible. The reason for this is because if for say you had 8 pieces of pie and you had to dived it evenly between zero people. Well as you can see you can't give any pizza out there for you can not divide it evenly out. So the answer to anything/0 = undefined like some other people have stated already.
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  13. #13
    Guest
    I'm disappointed to learn that 1/0 does not equal infinity (or should that be MAY not).

    at the tender age of about 12 I determined that infinity = a chocolate cake (on much the same principle as bulldogs post) as my dear friend Arbiter can attest.

    Now my illusions are shattered...

    (perhaps this is more suited for Chit-Chat)

  14. #14
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Behemoth - thou hairy man!

    I'm upset that you're claiming sole credit for the "infinity is a chocolate cake" theorem.

    Perhaps we should regale these people with other such theories (the multiverse is a toastrack...)

    I don't want to say lets go on over to chit chat again though.

    I think whether anything divided by zero equals infinity depends on what method you use to divide things. If you use the good old fashioned method of; keep subtracting the divisible number from the target number until you hit a number where subtracting further takes you past zero then you have the number of iterations and a remainder.

    If zero is the divisible number, you will perform this loop an infinite number of times...

    PS Both Behemoth and I have studied maths to a fair degree (though with no *formal* qualifications) and also remember when calculators weren't allowed in exams. This younger generation can even take in their maths text books to help them!! Can't remember quite as far back as the slide rule though...

    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  15. #15
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    windows calculator returns:
    Error: Positive Infinity

  16. #16
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    My Windows calculator reports 1/0 as "cannot divide by 0".
    Donald Sy - VB (ab)user

  17. #17
    Guest
    I vaguely remeber something in GCSE maths (oh no, im giving my age away!) that implies that if a calculation cannot be done, it is its own solution.
    Algebraic law:

    1/a = 1/a

    Therefore:
    1/0 = 1/0.

    no messing about. i think perhaps this is stretching rules a bit, but isnt that the whole point of logic?

  18. #18
    New Member
    Join Date
    Sep 2000
    Posts
    1

    Calculus proves that dividing by zero is infinity

    10/10=1
    10/1=10
    10/.1=100
    10/.01=1000
    ....
    10/.0000001=100000000

    As the value of the divisor gets smaller, the result gets bigger. In calculus, you say "x/y=infinity as y approaches 0".




  19. #19
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362

    Re: Calculus proves that dividing by zero is infinity

    Originally posted by arneljd

    As the value of the divisor gets smaller, the result gets bigger. In calculus, you say "x/y=infinity as y approaches 0".



    And the key word here is "approaches" - it does not say 0!
    Donald Sy - VB (ab)user

  20. #20
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    And for the ones that still aren't convinced, read it over at this site:
    http://www.drmath.com/dr.math/faq/faq.divideby0.html

  21. #21
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Cool Must have my two pennerth

    I don't mean to nitpick, but I must have a say in this argument...
    As the value of the divisor gets smaller, the result gets bigger. In calculus, you say "x/y=infinity as y approaches 0".
    I'm sure that you don't say x/y=infinity you say x/y -> infinity (x/y tends to or approaches infinity).


  22. #22
    Guest
    Actually... The appropriate definition of the 'division by zero' issue is:
    _________________

    Lim(a / x) = Infinity
    x -> 0

    Where 'a' represents a finite number.
    _________________

    By the way, did this thread answer your question?

    [Edited by Sc0rp on 09-20-2000 at 02:04 PM]

  23. #23
    Guest

    Red face

    Sorry Sc0rp, I didn't mean to cause offence.

    See, I reasoned that because you used the term "math" (an Americanism), you were American, and would have understood the irony of a Brit telling you how to speak English, (maths), however, I got it (and you) all wrong...

    please accept my apologies.

    BTW, what is your native language?

  24. #24
    Guest

    Thumbs up

    good lord Sc0rp, that wolfram site looks deep.

    You must understand, I dropped out of A-level maths because my teacher wasn't prepared to listen to my theories about imaginary numbers before we studied them (dont you hate it when teachers do that. you think you discover some incredible idea that would make life so much better, and they're not prepared to go through the theory with you and explain why it would or wouldn't work - mind you, Arbiter, McEwen was always a good one to try to blind with science)

    anyway, i digress. this site looks like just what i WANTED to study, and not what i was EXPECTED to study,

    cheers

  25. #25
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177

    Division by 0

    Print the procedure out, and walk through the data by hand. If that doesn't work then a neat trick to find out where the error is occuring, is to saturate the procedure(s) with message boxes (simply to find out where your error is occuring). Post your variable and the current value in the message box. You should place a message box after each equation line. This is not pretty but it will let you know where your error is occuring. If you discover that the error is a logical one then add 1, and that will eliminate the error. But you need to know where the error is occuring, so use the message boxes. You won't find that one in any class or book. That's what me and the boys call Computer Dope.

    The Computer Dope Man
    Doc Scheinder
    212 will lead you to the truth

  26. #26
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    that mathworld site is pretty complicated

  27. #27
    Guest
    Behemoth:
    • No offence taken.
    • I had a few teachers that wouldn't listen to anyone.
      Fortunately I am very patient...
    • My native language is Hebrew.

  28. #28
    Guest
    OK, you speak Hebrew and have just accepted an apology from someone calling themselves Behemoth...the world just gets weirder...

  29. #29
    Guest
    See my signature.

  30. #30
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Good night, you guys.

    I am 14, and last year I was bored during Geometry so I proved that division by zero leads to infinty. I used all the logic above and got myself smacked into independent study for it. By a teacher who has four degrees in math and has tought for decades.

    ITS INFINITY, OK?!?!?!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  31. #31
    Guest
    The simple answer is, division by zero = the cause of scottvb's problem. regardless of whether the final solution is infinity or not, this argument has the potential to be infinitely long. surely, because infinity is an imagined concept, it can be both infinity and NOT infinity at the same time?

  32. #32
    Guest
    Poor scottvb, all he wanted to know is how to solve his problem.

    scottvb: You can't divide by zero so either check if the divisor is zero and let the user know that division by zero is impossible, or set a default result value to be set when zero is detected.

Posting Permissions

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



Click Here to Expand Forum to Full Width