Drstein99 Posted May 17, 2004 Posted May 17, 2004 Is there any automatic data validation routines to take a date into a textbox? I need to user-input a date, and capture the text as string "MM/DD/YYYY", and control automatically guide the user if when they type a month beyond 12 or invalid date, in a standard text interface, no mouse pull downs, or any type of mouse control. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Joe Mamma Posted May 17, 2004 Posted May 17, 2004 Is there any automatic data validation routines to take a date into a textbox? I need to user-input a date' date=' and capture the text as string "MM/DD/YYYY", and control automatically guide the user if when they type a month beyond 12 or invalid date, in a standard text interface, no mouse pull downs, or any type of mouse control.[/quote']why no "mouse-ability"??? Using the DateTimePicker with ShowUpDown = true will force the user to type in data in the set format, but allow them to use the spin-edit controls to change settings The fact that you want no mouse control has me wondering about your overall design. Now you might be able to use the date time picker with ShowUpDown set to false and trap the mousedown event and cancel out so the calendar doesnt show. But again, not that you owe me any explanation, why??? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Drstein99 Posted May 17, 2004 Author Posted May 17, 2004 The entire U/I design of this application is predominately keyboard input, as required by my customer. And if I were asked to write an application that printed "I AM A DUMB HEAD" to the screen in a hideous font with puke-green background and poop-brown fore color, over and over until the machine was shut off; I would do what they asked and accept their money for my fabrication labor. Please dont suggest alternate implications, or tell me to re-think this. I asked for help regarding validating data straight up text for a date input, and that is all I need. These are the guidelines I must abide by to hold contracts in my private business. The BEST answer to your very inapropriate and way out of line "WHY" question is simple; Following orders to my responsibility and guaranteeing a stable future with the people I'm surrounded by. Thank you. why no "mouse-ability"??? Using the DateTimePicker with ShowUpDown = true will force the user to type in data in the set format, but allow them to use the spin-edit controls to change settings The fact that you want no mouse control has me wondering about your overall design. Now you might be able to use the date time picker with ShowUpDown set to false and trap the mousedown event and cancel out so the calender doesnt show. But again, not that you owe me any explanation, why??? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
blabore Posted May 17, 2004 Posted May 17, 2004 The datetimepicker control can be used without any mouse input, using F4 to show the calendar when it has the focus. However, if you must use a textbox, I'd suggest using a regular expression to validate the entered text after the control has lost focus/during the validate event. Otherwise you're going to have to handle keystrokes as the user types them, which might be a real mess due the different types of date formats.Using an ErrorProvider control also works well with this type of approach to notify your user of invalid data without having to display message boxes, etc. Just my 2 cents. Quote -Ben LaBore
Joe Mamma Posted May 18, 2004 Posted May 18, 2004 (edited) The entire U/I design of this application is predominately keyboard input, as required by my customer. And if I were asked to write an application that printed "I AM A DUMB HEAD" to the screen in a hideous font with puke-green background and poop-brown fore color, over and over until the machine was shut off; I would do what they asked and accept their money for my fabrication labor. Thank you.Well. . . As a responsible software engineer, I would explain to the customer that every control can be operated via key strokes if that is how they wish to use the interface and that using keystrokes is often more efficient in usage but that creating controls from the ground up is not a cost effective way to do things. Again. . . You can always trap the mouse events so the calendar never shows. but back to your statement. . . Just because a client wants square wheels because they look cool, I would not build them for him. How would I sell him off the idea? Explain that while an accomodating suspension would be feasible, its implementation would be extremely expensive. Hell, tell him to unplug his mouse :) I sold cars for 5 years before I went back to school to study systems engineering. Trust me, the customer doesnt always know what he really wants. Solving problems efficiently is my responsibility. The fact that no mouse input is desired throws a red flag that the client doesnt completely understand his task or his tools. I would be afraid that the solution he believes should be implemented would not be the best for the task at hand. I want to deliver to my clients the best solution for their money. That is my responsibilty. My only reason for asking why is that I might have been able to identify the flaw in your clients approach to solving the problem and suggest a way to communicate an alternate idea to the client that he would be open to. Delivering a poor solution, no matter how badly the client desires it is NEVER a responsible act. In the end, someone else will come by and say to the client 'you know you could have done it like this and it would have been more practical, cheaper and efficient.' Believe me, the client will not remember that he came up with the design himself. Instead, he will blame you for not talking him out of it and think you ripped him off because you weren't looking out for his interests. Implementing a bad design will never guarantee a stable financial future. Effective software engineering has little to do with actual coding. Clients want value being it a new car or a new software system. I wouldnt program in VB just because my client cant read any other language. I would take 5 minutes and demonstrate why vb is inferior. I want five minutes in front of your client. Edited May 18, 2004 by Joe Mamma Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Drstein99 Posted May 18, 2004 Author Posted May 18, 2004 Once again. I asked for help on my technical situation. I'm going to explain a little more, for the sheer morbid interest of satisfying what clearly is none of your business with my customer. This is a data entry firm. Hundreds of people use this system, and when they take diction or read from handwritten sheets they fill out the fields, THEY DONT want THEIR EMPLOYEES (which some are senior citizens, handicaps, unfamiliar with GUI, and others are extreme fast typers). They dont want to move from the keyboard to the mouse every time there is a date field input. They dont want to become distracted by some graphics on the screen and use arrow keys to pick and select. TIME IS MONEY, when it boils to keystrokes and fast easy operation here. I have been programming for years. I have my orders. This project is a result in a plethora of hours in research and decision making by more than just one person. You want 5 minutes with my customer? We just met - and I already dont like your approach to helping me with my situation. I dont even want to give you five minutes of my own time. To What? Explain myself to you and have you tell me different? I dont have time for that. I've already made it clear that other design suggestions will not help me. ------------------------------------------------------------- Back to the nature of the original post, please someone could professionally advise help: I have a textbox (or for that matter I DONT CARE WHAT TYPE OF BOX that can be tabbed into). I want the user to type in a date as follows "MM/DD/YYYY", and handle date validation. Well. . . As a responsible software engineer, I would explain to the customer that every control can be operated via key strokes if that is how they wish to use the interface and that using keystrokes is often more efficient in usage but that creating controls from the ground up is not a cost effective way to do things. Again. . . You can always trap the mouse events so the calendar never shows. but back to your statement. . . Just because a client wants square wheels because they look cool, I would not build them for him. How would I sell him off the idea? Explain that while an accomodating suspension would be feasible, its implementation would be extremely expensive. Hell, tell him to unplug his mouse :) I sold cars for 5 years before I went back to school to study systems engineering. Trust me, the customer doesnt always know what he really wants. Solving problems efficiently is my responsibility. The fact that no mouse input is desired throws a red flag that the client doesnt completely understand his task or his tools. I would be afraid that the solution he believes should be implemented would not be the best for the task at hand. I want to deliver to my clients the best solution for their money. That is my responsibilty. My only reason for asking why is that I might have been able to identify the flaw in your clients approach to solving the problem and suggest a way to communicate an alternate idea to the client that he would be open to. Delivering a poor solution, no matter how badly the client desires it is NEVER a responsible act. In the end, someone else will come by and say to the client 'you know you could have done it like this and it would have been more practical, cheaper and efficient.' Believe me, the client will not remember that he came up with the design himself. Instead, he will blame you for not talking him out of it and think you ripped him off because you weren't looking out for his interests. Implementing a bad design will never guarantee a stable financial future. Effective software engineering has little to do with actual coding. Clients want value being it a new car or a new software system. I wouldnt program in VB just because my client cant read any other language. I would take 5 minutes and demonstrate why vb is inferior. I want five minutes in front of your client. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
pendragon Posted May 18, 2004 Posted May 18, 2004 The following link will take you to a page where someone has written the old MaskEditBox that was in VB6 for .NET. Maybe this will work for you. http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp?target=maskedit Quote
Joe Mamma Posted May 18, 2004 Posted May 18, 2004 and why won't the date time picker work??? alt down arrow to display the calendar, use page up down to select month, ctl+page up/down for year. . . want to type in numbers then set format to short to type in numbers. . . Don't rebuild the wheel. Datetime picker does exactly what you want it to do with the added functionality of being able to use the mouse. they dont have to use a mouse if they dont want to, but if they want to, they can. Dont want them to use the mouse, grab mouse events and cancel them. Its your attitude that smacks of arrogance, my friend. Again, I just asked why in order to overcome your clients objections to having a 'mouse' capable control for handling dates. the truth is there is no objection, just a lack of understanding. Not only on their part but yours. Why do I want five minutes in front of your customer? Because you are trying to charge them for something that they don't need just because you dont know how a control works, lack the ability to communicate effectively, and ultimately dont care about them. And it is working with clients who have been treated similarly that assures my financial stability. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Drstein99 Posted May 18, 2004 Author Posted May 18, 2004 The picker works to enter a straight text date, in short format. There is a mouse control drop down, I'd like to get rid of. Dont see a property to remove this. To validate the data this may do the job, however will need to reconstruct many other classes because it's not a text box. I will experiment. ------------------------------------------------- and why won't the date time picker work??? alt down arrow to display the calendar, use page up down to select month, ctl+page up/down for year. . . want to type in numbers then set format to short to type in numbers. . . Don't rebuild the wheel. Datetime picker does exactly what you want it to do with the added functionality of being able to use the mouse. they dont have to use a mouse if they dont want to, but if they want to, they can. Dont want them to use the mouse, grab mouse events and cancel them. Its your attitude that smacks of arrogance, my friend. Again, I just asked why in order to overcome your clients objections to having a 'mouse' capable control for handling dates. the truth is there is no objection, just a lack of understanding. Not only on their part but yours. Why do I want five minutes in front of your customer? Because you are trying to charge them for something that they don't need just because you dont know how a control works, lack the ability to communicate effectively, and ultimately dont care about them. And it is working with clients who have been treated similarly that assures my financial stability. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Joe Mamma Posted May 18, 2004 Posted May 18, 2004 The picker works to enter a straight text date, in short format. There is a mouse control drop down, I'd like to get rid of. Dont see a property to remove this. To validate the data this may do the job, however will need to reconstruct many other classes because it's not a text box. I will experiment. ------------------------------------------------- for the last time: trap the mouse event and cancel. and the datetimepicker, at a low level, IS a text box with all the functionallity you desire. . . but still who really cares if it has mouseability??? the control works exactly as you want it to work with the additional feature of being able to use a mouse, if the user so desires. there is no stipulation that the user MUST use a mouse to set the date. And using a mouse is often the slow way to do things, I agree. But having a desire to type in the dates is not sufficient reason to spend VALUABLE time designing a new control. That is what the client does not understand. I mean if I was selling a car and they didnt want a cdplayer but the car came with one anyway at no additional charge, I would suggest they just not put the cd in the player, or they can pay me to have it removed. And paying to have the cd player removed just because they own no cd's is ridiculous! 999 out of 1000, they will say, "well who cares? I like having the ability of being able to play a cd if I ever desire to in the future" I urge you to sell them that idea, save them that money so they have a little more money to spend on the REAL NEAT idea that I am SURE you will come up with down the line!!! I'm reminded of groucho marx. . . Patient: Doc, it hurts when I do this. Groucho: Then don't do that. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Drstein99 Posted May 18, 2004 Author Posted May 18, 2004 Please explain how all this information helps me to validate a date input on a text box control. Because thats all I care to listen to. for the last time: trap the mouse event and cancel. and the datetimepicker, at a low level, IS a text box with all the functionallity you desire. . . but still who really cares if it has mouseability??? the control works exactly as you want it to work with the additional feature of being able to use a mouse, if the user so desires. there is no stipulation that the user MUST use a mouse to set the date. And using a mouse is often the slow way to do things, I agree. But having a desire to type in the dates is not sufficient reason to spend VALUABLE time designing a new control. That is what the client does not understand. I mean if I was selling a car and they didnt want a cdplayer but the car came with one anyway at no additional charge, I would suggest they just not put the cd in the player, or they can pay me to have it removed. And paying to have the cd player removed just because they own no cd's is ridiculous! 999 out of 1000, they will say, "well who cares? I like having the ability of being able to play a cd if I ever desire to in the future" I urge you to sell them that idea, save them that money so they have a little more money to spend on the REAL NEAT idea that I am SURE you will come up with down the line!!! I'm reminded of groucho marx. . . Patient: Doc, it hurts when I do this. Groucho: Then don't do that. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Joe Mamma Posted May 18, 2004 Posted May 18, 2004 (edited) Please explain how all this information helps me to validate a date input on a text box control. Because thats all I care to listen to.As I have said from the beginning: use the datetime picker set the format to shortdate set showupdown to true so they dont get the calender datetimepicker allows for text input. datetimepicker prevents invalid text input. If they dont want to use the mouse, thats fine, they dont have to use their mouse. [edit]Removed unnecessary insult.[/edit] Edited May 20, 2004 by mutant Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
*Experts* Volte Posted May 20, 2004 *Experts* Posted May 20, 2004 Everyone settle down, or I'm locking this thread. There is no need for hostility here. Joe Mamma, you have been warned about your obnoxious and public disdain towards Visual Basic and its users. Personal insults especially will not be tolerated. Quote
*Experts* jfackler Posted May 20, 2004 *Experts* Posted May 20, 2004 (edited) An Answer Dr I had a similar issue: had 70 text boxes that an administrator needed to edit on occasion. To wit: employees entered clock-in and clock-out times via a time stamp formated by the code, but I wanted the admin to be able to freely enter times in a specific format in the textboxes on a summary form of the employees biweekly hours when they (as humans will) screwed up. I needed to guard against a daft administrator however, and so created the errorprovider code that follows to assure he/she put the time in in the format my code expected. I think you can tweak the code to make it work for you. The first bit adds a handler to all the textboxes on the form. The second does the heavy lifting via a regex to check the format. Imports System.Text.RegularExpressions Dim tbo As TextBox Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is TextBox Then tbo = CType(ctrl, TextBox) AddHandler tbo.Validating, AddressOf tboerrorHandler End If Next And the second part: Private Sub tboerrorHandler(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Dim tb As TextBox tb = CType(sender, TextBox) If Not tb.Text = "" Then Dim myregex As New Regex("[0-9]{1,2}:[0-9]{2}\sAM|PM") If Not myregex.IsMatch(tb.Text) And Not tb.Text = "" And Not tb.Text = "PTO" Then ErrorProvider1.SetError(tb, "Input must be in the format HH:mm AM/PM or PTO") Else : ErrorProvider1.SetError(tb, "") End If Else : ErrorProvider1.SetError(tb, "") End If End Sub PTO in the above designates an abreviation allowable in the code as well...stands for Paid Time Off (something I wish I was fortunate enough to recieve). Hope it helps....and sorry for the grief you took up to this point. Jon Edited May 20, 2004 by jfackler Quote
Joe Mamma Posted May 20, 2004 Posted May 20, 2004 (edited) The picker works to enter a straight text date' date=' in short format. There is a mouse control drop down, I'd like to get rid of. Dont see a property to remove this.[/quote']again set showupdown = true then no dropdown calendar. yes there are spinedits. . . hmmm. . . I just had an idea. . . a brilliant one if I may say so myself. . . :) put a text box on the form. also put a hidden datetime picker trap the key pressed event on the textbox, grab the key, calculate the resulting text and send it to the datetime picker and cancel so the textbox's text doesnt actually change. then in the onchange event of the datetime picker, update the textbox value with the datetime pickers value. That is, utilize the datetimepicker's validation routines to verify the input into the text box. sorry if I rubbed people the wrong way. I just passionately believe that reimplementing already existing functionality is not good practice. I mean, Microsoft has more time and money to write and debug all those little annoying yet vital algorithms. Our time as developers is better used weilding their solutions than it is debugging our own. What do you think? Edited May 20, 2004 by Joe Mamma Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
mooman_fl Posted May 20, 2004 Posted May 20, 2004 Ok.... solution first: three text boxes on the form with two labels with a "/" as their text (1 between the first and second textboxes... and the second between textboxes 2 and 3).... then validating is as simple as using if statements in the OnChange event for each textbox to make sure that the input is a) numeric, b) the right length, and c) in the right range.... if not then reset the contents of the textbox. Upon submission of this form the three textboxes can be concatenated to what ever desired format the programmer wants. Many webpages use this same method or something similar. That having been said, I don't know what the insult Joe Mamma had made... but other than that I have to agree with him. I was immediately insulted by Drstein99's first response to Joe. It was arrogant and rude coming from someone that was here asking US for help. I would suggest that if any further help is wanted that fact should be kept in mind by the asker. Secondly... not only does the customer not always know what they want, often times the programmer doesn't either. This has been proven time and time again on this very forum (even I have been guilty of needing to be shown the light and a better way). Asking why is not only a time honored tradition here... but often times necessary to understanding the true nature of the problem. A simple "I have no choice about no mouse input... and I have to keep it to the most simple methods per the clients request" would have sufficed for me and most other forum members here. That having been said... Have a nice day :) Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.