Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > Visual Basic 2010 General Discussion
|
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion 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 March 21st, 2011, 01:43 PM
Authorized User
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I add a message box or alert to a MaskTextbox if the user enters no numbers?

Hello everyone.

I have a MaskedTextbox which takes Us Phone numbers.
Using The MaskedTextBox ensures the user can enter only numbers and the number gets formatted right.

Here is the problem I am having: How do I add an error message if the box is left empty? I am not trying to validate the number, just need a way to add: "You forgot to enter a number." Can I add this to a MaskedTextBox?

How do I add a message box or alert to a MaskTextbox if the user hit submit without entering numbers?

Thanks everyone!

PGM
 
Old March 21st, 2011, 01:50 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Code:
If mytextBox.text = String.IsEmpty Then

End If
String.IsEmpty is possibly a function, if so:

Code:
If String.IsEmpty(myTextBox.Text) Then
'is empty
End If
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old March 21st, 2011, 05:26 PM
Authorized User
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Apocolypse2005 View Post
Code:
If mytextBox.text = String.IsEmpty Then

End If
String.IsEmpty is possibly a function, if so:

Code:
If String.IsEmpty(myTextBox.Text) Then
'is empty
End If
This wouldn't work because we are talking about numbers not strings.
Because the MaskedTextBox is set to collect phone number.

I get the following error message.

IsEmpty is not a member of string.


Any other ideas?

Thanks Again

PGM
 
Old March 23rd, 2011, 06:21 AM
Authorized User
 
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default no entry alert

you Could use the IsNumeric()

Code:
 
IF Not IsNumeric(myTextBox.Text)  Then MSgBox "You forgot to enter a number."
OR LEN()
Code:
 
IF Len(myTextBox.Text) < 1 Then MSgBox "You forgot to enter a number."
 
Old March 25th, 2011, 04:49 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by NovicePGM2011 View Post
This wouldn't work because we are talking about numbers not strings.
Because the MaskedTextBox is set to collect phone number.

I get the following error message.

IsEmpty is not a member of string.


Any other ideas?

Thanks Again

PGM

IsNullOrEmpty . . . . . ring any bells?

Plus your not looking at numbers, your looking at strings, regardless of the input data! Your checking whether the input is empty or not, then you check whether a number was entered, then you check the min max and all your other validations!

The Property of the maskedtextbox which holds the input is called .Text am I correct, then if I am correct surely the data type of said property is a string! The data type doesnt change dynamically with the input otherwise it would have data type object!
__________________
Apocolypse2005, I'm a programmer - of sorts.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Message Box and then fire as required answer by User. HG8YV2D ASP.NET 3.5 Professionals 3 February 22nd, 2010 09:19 AM
flashing alert message semooth Access 2 February 3rd, 2006 01:00 PM
Security Alert Message Maxood Beginning PHP 5 July 12th, 2004 02:09 PM
Alert Message ferfish Classic ASP Basics 1 May 16th, 2004 06:43 PM
Security Alert Message box pkgal79 HTML Code Clinic 5 June 12th, 2003 09:20 AM





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