Results 1 to 5 of 5

Thread: divide by zero while entering a numeric value that begins with 0

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Location
    San Diego, CA
    Posts
    19

    divide by zero while entering a numeric value that begins with 0

    basically I have a textbox

    Code:
        Private Sub txt_NumberA_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_NumberA.TextChanged
            
            Try
                NumberA = Decimal.Parse(txt_NumberA.Text)
            Catch ex As Exception
                MsgBox("This program requires a numeric input.  Please try again. Enter .500 as 0.500.")
                Return
            End Try
            
            NumberB = 5.0
            
            NumberC = NumberB/NumberA
    
    lbl_NumberC.Text = NumberC
    
        End Sub


    I have no problem entering any number that does not start with a zero, however, if I want to enter 0.5 in, then as I type in '0', then I have division by zero and the program crashes.

    Could you please help me to fix this? Many thanks,

    Nina
    Last edited by nina_le_huynh; Feb 24th, 2008 at 04:21 AM.

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