473,461 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Function to validate time

Can i get a function to validate time eneterd in a text box
Jul 21 '07 #1
5 6072
hariharanmca
1,977 1GB
Can i get a function to validate time eneterd in a text box
Expand|Select|Wrap|Line Numbers
  1. Method:
  2. Format(TimeValue,<Time Format>)
  3.  
  4. Example :
  5. Format(txtTextBoxName.Text,"hh:mm:ss AM/PM")
this will help you
Jul 21 '07 #2
hariharanmca
1,977 1GB
Can i get a function to validate time eneterd in a text box
using text box for reciving Time from User is not good practice

Suggest you to use DTPicker.
Jul 21 '07 #3
Thnx
The format string string helped.
though i am not using DTPicker as it it is not user friendly
Jul 21 '07 #4
hariharanmca
1,977 1GB
Thnx
The format string string helped.
though i am not using DTPicker as it it is not user friendly
(I never thought) No Problem, Better validate tour text box.
Jul 21 '07 #5
Killer42
8,435 Expert 8TB
Can i get a function to validate time eneterd in a text box
Yes, the datetimepicker control has both good and bad points. It's not always appropriate.

One thing you might try, (not sure whether it's available in all versions) is the "Microsoft Masked Edit Control" (add in under Project | Components). This allows you much more control over the input than a standard textbox. Of course, you may still need to validate afterward, but at least you can enforce the general format of the input.

As for validating, perhaps the simplest way is to turn on error handling and try to convert the value to a time. For example (VB6)...

Expand|Select|Wrap|Line Numbers
  1. Dim T As Date
  2. Dim S As String
  3. ' Assuming your value is in S...
  4. On Error Resume Next
  5. T = TimeValue(s)
  6. If Err.Number Then
  7.   Err.Clear
  8.   ' Not a valid time.
  9. End If
  10. On Error GoTo 0
Jul 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Konstantin Zakharenko | last post by:
Hello, Our QA team have running a lot of test scripts (for automated regression testing), they run them on the different databases (Oracle/MS SQL). Several of those tests are dependent on the...
8
by: Steve Leferve | last post by:
Is there an easy way to validate with VBA that a user entered a time value into a text box? I didn't see anything in the validation options on the text box properties. Steve
3
by: Claire | last post by:
I have a large record with many enumerated fields. The record is stored in a file and the fields have to be extracted. I validate the data as it's read, but there's so many tests similar to the...
1
by: z. f. | last post by:
in my custom validator ServerValidate function i set args.IsValid = False but the page execution continues like the page is valid and the validation summary doesn't show the error message . how...
1
by: ApexData | last post by:
Hello I have an UNBOUND textbox Text1 that I want to validate in code. I want to lock the user into the field until Valid Data is entered. I created the following Function: Private Function...
2
by: cryme | last post by:
Im having a minor, simple problem. Basicly i have two different scripts they both work separately and together but just that both executes at the same time. On my html page i have a form, one of...
6
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we...
1
by: Randeh | last post by:
Newb C++ problem, arithmetic functions are returning 0 values each time. Not sure where the problem is, but I've run checks and it seems to be going fine until the very end where the arithmetic...
12
by: pyramid | last post by:
I am new to C++, and one of the homework we have pertains to Functions. The problem is: Write a function called isValid that determines whether any 3 values can represent the sides of a...
2
by: phpentrylevel | last post by:
hello i am a newbie to Javascript with a in depth background of PHP i have a simple script that replaces missing images when the webpage loads but i just cant get it to validate in JLint as my...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.