LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2011, 07:38 AM   #1
BMan8577
Member
 
Registered: Apr 2011
Posts: 73

Rep: Reputation: 0
I have to develop a case logic and validate text box control so it is not empty.


I need to validate a name TextBox control so that it is not empty in which an error message will be displayed, and set the focus back to the name's control. I must use a Case Logic that when a city is typed in, the county shows in the Textbox entry. For example "mentor" will be "lake" county. This is for my class, I have read the instructor's examples and read the chapter. I am still having trouble under standing the Case Logic. Here is the code that I have so far. Thanks guys I will even give you reputation and credit for my work. Thanks. How do I get it to pop up the error message if another button is clicked before the name's TextBox is entered?


Public Class Form1

Private Sub PatientTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PatientTextBox.TextChanged

If PatientTextBox.TextLength = 0 Then
MessageBox.Show("Please input the patient's name to proceed.", "ErrorMessage")
ElseIf PatientTextBox.Text = "" Then
PatientTextBox.Text = PatientTextBox.ToString
End If

End Sub

Private Sub TeenRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TeenRadioButton.CheckedChanged
If TeenRadioButton.Checked = True Then
AgeTextBox.Text = "Teenager"
ElseIf YoungAdultRadioButton.Checked = True Then
AgeTextBox.Text = "Young Adult"
End If
End Sub

Private Sub MidAgeRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MidAgeRadioButton.CheckedChanged
If MidAgeRadioButton.Checked = True Then
AgeTextBox.Text = "Middle Age Person"
ElseIf SeniorRadioButton.Checked = True Then
AgeTextBox.Text = "Retirement Age"
End If
End Sub

Private Sub CountyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CountyTextBox.TextChanged

Select Case CityTextBox.Text
Case "Mentor"

Case "Kirtland"

Case "Painesville"

Case "Euclid"

End Select

Select Case CountyTextBox.Text
Case "Lake"

Case "Lake"

Case "Lake"

Case "Cuyahoga"
End Select

End Sub
End Class

Last edited by BMan8577; 09-23-2011 at 07:58 AM.
 
Old 09-23-2011, 10:12 AM   #2
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
http://en.wikipedia.org/wiki/Switch_...A.2C_VB_Script

I'm not familier with VB to tell you the best way to handle that error sitation, but I'd suggest taking the check you have inside where you handle PatientTextBox.TextChanged, put it in a function, and call it within each Handles block.

Might you not also disable the other controls from being used while PatientTextBox.TextLength = 0, and when PatientTextBox.TextChanged occurs and PatientTextBox.TextLength > 0, enable them? Not forgetting to disable them again if/when PatientTextBox.TextLength = 0 in subsequent PatientTextBox.TextChanged handlings.

Last edited by Proud; 09-23-2011 at 10:19 AM.
 
Old 09-23-2011, 01:57 PM   #3
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
If you need the notification before another button is clicked, you can examine the input focus state or handle key/mouse events.
This is deliberately vague, I know. The specific answers are in the MSDN Help entries for CWnd.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty Control Center mousomer Linux - Desktop 3 02-19-2009 09:45 AM
How to Control TTL Logic w/ Linux Johnsernickle Linux - Software 4 08-05-2008 01:34 PM
Empty gnome control center TruckStuff Linux From Scratch 2 04-06-2005 09:33 PM
Gentoo VNC, empty dialog box !! "Question" window is empty ! TheHushedCaskeT Linux - Software 0 02-01-2005 10:14 PM
Empty KDE Control Center matos Linux - General 0 01-15-2002 11:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration