Advertisement

05.23.2008 at 01:25PM PDT, ID: 23428881
[x]
Attachment Details

try catch and message box in visual basic 2005

Asked by systems_ax in Visual Studio .NET 2005, Visual Basic Programming, Microsoft Visual Basic.Net

i am developing with visual basic 2005 and need a message to display informing me that I can only enter required info into a text box control on my form.  Currently I can only enter "numbers and letters only" itno my text box which is great because this is exactly what I need. So, mt text box does not allow any spaces or special characters.
What I need to do is implement a try/catch block for purposes when I try to enter a space or any special character, I will see a message informing me that "I cannot enter spaces or special characters".

This is my entire working code:
If Not (e.KeyCode >= Keys.NumPad0 And e.KeyCode <= Keys.NumPad9) And Not (e.KeyCode >= Keys.D0 And e.KeyCode <= Keys.D9) And Not (e.KeyValue >= Keys.A And e.KeyValue <= Keys.Z) Or e.Shift Or e.KeyCode = Keys.Space Then
       If e.KeyCode <> Keys.Delete And e.KeyCode <> Keys.Back Then
        e.SuppressKeyPress = True
       End If

but hod do I embed it into try and catch.
I tried the folliwng but message is being displayed.
Can someone please shed some light on what I am doing wrong?
thank youStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Try
            If Not (e.KeyCode >= Keys.NumPad0 And e.KeyCode <= Keys.NumPad9) And Not (e.KeyCode >= Keys.D0 And e.KeyCode <= Keys.D9) And Not (e.KeyValue >= Keys.A And e.KeyValue <= Keys.Z) Or e.Shift Or e.KeyCode = Keys.Space Then
                If e.KeyCode <> Keys.Delete And e.KeyCode <> Keys.Back Then
                    e.SuppressKeyPress = True
                End If
            End If
        Catch
            If (e.KeyCode >= Keys.D0 And e.KeyCode <= Keys.D9) And e.KeyCode <> Keys.Space Then
                MsgBox("Only single numbers and letters are allowed.", MsgBoxStyle.OkOnly, "Information")
            End If
 
        End Try
 
 
[+][-]05.23.2008 at 01:32PM PDT, ID: 21635597

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 01:36PM PDT, ID: 21635623

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 01:47PM PDT, ID: 21635704

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:17PM PDT, ID: 21635904

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:33PM PDT, ID: 21635993

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:38PM PDT, ID: 21636012

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:40PM PDT, ID: 21636022

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:48PM PDT, ID: 21636065

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:52PM PDT, ID: 21636083

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 03:18PM PDT, ID: 21636193

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio .NET 2005, Visual Basic Programming, Microsoft Visual Basic.Net
Sign Up Now!
Solution Provided By: jpaulino
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.23.2008 at 04:00PM PDT, ID: 21636553

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 04:31PM PDT, ID: 21636769

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 04:31PM PDT, ID: 21636773

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 08:41AM PDT, ID: 21652827

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 09:20AM PDT, ID: 21653207

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 10:17AM PDT, ID: 21653690

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 11:02AM PDT, ID: 21654096

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 12:32PM PDT, ID: 21654873

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 02:09PM PDT, ID: 21655745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 02:52PM PDT, ID: 21656070

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 02:55PM PDT, ID: 21656088

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 03:04PM PDT, ID: 21656154

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 03:07PM PDT, ID: 21656178

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 03:14PM PDT, ID: 21656232

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 03:19PM PDT, ID: 21656252

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 03:41PM PDT, ID: 21656345

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 03:43PM PDT, ID: 21656352

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 06:00PM PDT, ID: 21656925

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628