Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2007, 01:42 AM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx I got everything done, but I have the last one problem. I got everything, except one thing.
Everytime I type in a letter in a textbox, it would make an error pointing out this code:
Code:
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text = "" Then
            TextBox1.Text = 0
        End If
        If TextBox1.Text > 45 Then

            If MsgBox("0~45", MsgBoxStyle.Exclamation, "Change number") = MsgBoxResult.Ok Then
                TextBox1.Text = 0
            End If
        End If
        If TextBox1.Text = "" Then
            TextBox1.Text = 0
        End If
    End Sub


It would highlight the Textbox1.Text > 45 part.
THis is the part when I type in something higher than 45, a thing comes out where it says the number should be 0~ 45.
 
Old May 23rd, 2007, 07:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. if you enter a letter (or a space, or a comma) it will try to cast the text to a number and fail, ("a" is not a number), so you have to choice:
Get from internet a textbox that only accepts numbers or,
try to verify is the box only has numbers, and if not reject the change (you can do this in the keydown event, see wich key the user press, and if not a number cancel the press)...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 23rd, 2007, 06:30 PM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you know on visual basic 5.0 or 6.0 there is an "isnumeric = True/False" thing, is there such stuff on visual basic 2005??

 
Old May 23rd, 2007, 09:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

the isnumeric function still exist inside the namespace Microsoft.VisualBasic
(http://msdn2.microsoft.com/en-us/lib...w1(vs.80).aspx)

but you better use double.tryparse (doesn't return an error, is just return a boolean)
http://support.microsoft.com/?scid=k...9488&x=14&y=20

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Date in Visual Basic 2005. sheelnathkekre Visual Basic 2005 Basics 1 August 15th, 2008 09:42 AM
visual basic 2005 nidhigupta001 Visual Basic 2005 Basics 1 February 12th, 2007 08:26 AM
visual basic 2005 nidhigupta001 Visual Basic 2005 Basics 2 February 11th, 2007 04:06 PM
FTP in Visual Studio 2005 Pro (Visual Basic) shoopes VB How-To 1 June 29th, 2006 02:08 PM
Visual basic.net (Lottery program) Brettvan1 VB.NET 2002/2003 Basics 10 October 1st, 2004 08:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.