Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 23rd, 2007, 12:53 PM   #1
garyelmer
Newbie
 
Join Date: Oct 2007
Posts: 8
Rep Power: 0 garyelmer is on a distinguished road
'ErrMessage' is not declared

I am VB 2005 Student

I'm trying to validate some user input using the code provided in the textbook.
It uses "ErrMessage" as shown in the code below:

'  Validate input for January

        If IsNumeric(txtJan.Text) Then
            Dim sngValue As Single
            sngValue = CSng(txtJan.Text)
            If sngValue < 0 Then
                txtJan.SelectAll()
                e.Cancel = True
            Else
                e.Cancel = False
            End If
        Else
            ErrMessage("The input must be a number")
            e.Cancel = True
        End If
I'm getting an Error Message saying that ErrMessage is not declared and the textbook doesn't have any details about this statement. What's wrong?
I could use MessageBox.Show("blah blah blah") but the textbook uses ErrMessage as shown above.

Gary

Last edited by DaWei; Oct 23rd, 2007 at 1:23 PM. Reason: Added code tags. Read the rules.
garyelmer is offline   Reply With Quote
Old Oct 23rd, 2007, 1:30 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: 'ErrMessage' is not declared

Write a sub, ErrMessage, that takes a string and throws up the MessageBox with the appropriate decorations.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 23rd, 2007, 11:37 PM   #3
garyelmer
Newbie
 
Join Date: Oct 2007
Posts: 8
Rep Power: 0 garyelmer is on a distinguished road
Re: 'ErrMessage' is not declared

We haven't gotten to writing sub-routines or functions yet so I settled for a MessageBox.

Thank you for the reply though.

Gary
1st Semester VB.Net Student
garyelmer is offline   Reply With Quote
Old Oct 24th, 2007, 12:52 AM   #4
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
Re: 'ErrMessage' is not declared

Just in case you're wondering, ErrMessage probably would have been declared somewhere in the code in your book. If it's not, might I suggest getting a new book? I know some books are horribly notorious for this. What book are you using?
Booooze is offline   Reply With Quote
Old Oct 24th, 2007, 12:23 PM   #5
garyelmer
Newbie
 
Join Date: Oct 2007
Posts: 8
Rep Power: 0 garyelmer is on a distinguished road
Re: 'ErrMessage' is not declared

The Text Book is " Starting Out With Visual Basic 2005" by Tony Gaddis and Kip Irvine. Just in case you have the book the ErrMessage in their example code appears on page 315 and isn't declared anywhere in section 5.7 dealing with error validation. It's not a bad text in my newbial opinion but it did confuse the heck out of me until I decided to ignore it and call a MessageBox instead.

Gary
garyelmer is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling Maverik 6.2 (from C) megamind5005 C 16 May 3rd, 2006 5:41 PM
'NULL' was not declared in this scope titaniumdecoy C++ 9 Mar 24th, 2006 3:00 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC