Error Catching Visual Basic 2005


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Error Catching Visual Basic 2005

  1. #1
    Join Date
    Apr 2007
    Posts
    10

    Error Catching Visual Basic 2005

    Hey Everyone,

    I would like to validate that the input entered in is greater than 0 or is not blank. The problem that I am having with my code is that it will give the message but will continue on with the program and output the results. I would like for the program to stop and allow the user to correct the input value.


    Code:
     Sub DataInput()
            err1 = "Please enter a value greater than zero"
            numDays = txtDays.Text
            If numDays <= 0 Or Nothing Then
                MsgBox(err1)
            End If
          
        more code here
    
    End Sub

  2. #2
    Join Date
    Dec 2004
    Posts
    163
    war4tek,

    Write the code in the textbox's Validating event.

    If the data in the textbox does not pass your validation rules, set e.Cancel = True to keep the user from leaving the textbox.

    Kerry Moorman

  3. #3
    Join Date
    Apr 2007
    Posts
    10
    Thanks!

Similar Threads

  1. Visual Basic 6.0 Code Advisor
    By Patrick Troughton in forum .NET
    Replies: 0
    Last Post: 01-31-2003, 01:09 PM
  2. yag's status report - April 11, 2002
    By Yair Alan Griver [MS] in forum vb.announcements
    Replies: 0
    Last Post: 04-11-2002, 08:33 PM
  3. yag's status report - April 4, 2002
    By Yair Alan Griver [MSFT] in forum vb.announcements
    Replies: 0
    Last Post: 04-04-2002, 09:28 PM
  4. YAG's public status report - March 7, 2002
    By Seth Grossman [MSFT] in forum vb.announcements
    Replies: 1
    Last Post: 03-13-2002, 07:32 PM
  5. YAG's status report - Feb 14, 2002
    By Seth Grossman [MSFT] in forum .NET
    Replies: 1
    Last Post: 02-15-2002, 12:35 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center