Very simple question - PLEASE HELP !!! :-) 
Author Message
 Very simple question - PLEASE HELP !!! :-)

This should be easy for most of you. I'm writing a simple, little VB5
app. that adds two times together, using the DateAdd method. I simply
want to know how to test the user's input (InputBox$) for whether or not
they have entered a valid time (00:00:00 - 23:59:59). I'd like to trap
the error and prompt the user with a MsgBox to tell them to do re-enter
the time. I've got everything down but how to test the input for a valid
time (date) format, e.g. "00:35:55". For the life of me, I can't figure
it out. It's gotta be simple... Any help is GREATLY appreciated! THANKS,

Bubba



Wed, 09 May 2001 03:00:00 GMT  
 Very simple question - PLEASE HELP !!! :-)
Try to use this one:

on local error resume next ' ignore error messages
newdate=datevalue(inputbox("Enter a date")) ' store new date in NewDate
if err then msgbox "Invalid date format"' is error: display it
on error goto 0' disable error trapping

Good luck, Jacco.

P.s. There is alsoo a timevalue=function !

Quote:

>This should be easy for most of you. I'm writing a simple, little VB5
>app. that adds two times together, using the DateAdd method. I simply
>want to know how to test the user's input (InputBox$) for whether or not
>they have entered a valid time (00:00:00 - 23:59:59). I'd like to trap
>the error and prompt the user with a MsgBox to tell them to do re-enter
>the time. I've got everything down but how to test the input for a valid
>time (date) format, e.g. "00:35:55". For the life of me, I can't figure
>it out. It's gotta be simple... Any help is GREATLY appreciated! THANKS,

>Bubba




Thu, 10 May 2001 03:00:00 GMT  
 Very simple question - PLEASE HELP !!! :-)
Bubba,
You can use the 'IsDate' function for a date and/or time string, eg....
        Dim strTime As String
        strTime = "23:59:60"
        If Not IsDate(strTime) Then
        MsgBox "Not a valid time!"
        End If
--
Regards, John


Quote:
> This should be easy for most of you. I'm writing a simple, little VB5
> app. that adds two times together, using the DateAdd method. I simply
> want to know how to test the user's input (InputBox$) for whether or not
> they have entered a valid time (00:00:00 - 23:59:59). I'd like to trap
> the error and prompt the user with a MsgBox to tell them to do re-enter
> the time. I've got everything down but how to test the input for a valid
> time (date) format, e.g. "00:35:55". For the life of me, I can't figure
> it out. It's gotta be simple... Any help is GREATLY appreciated! THANKS,

> Bubba




Thu, 10 May 2001 03:00:00 GMT  
 Very simple question - PLEASE HELP !!! :-)
These are two functions I use to determine the date and time values for a
given input.  If the result is and empty string or vbNullString, then the
entry is invalid.

'----------------------------------------------------
' Description:
'   Convert a given string into a valid date.
'
' Inputs:
'   SourceText = string to be converted to a date
'
' Returns:
'   TextToDate = date value of the string
'----------------------------------------------------
Public Function TextToDate( _
    ByVal SourceText As String) As String

    If IsDate(SourceText) Then
        TextToDate = DateValue(SourceText)
    Else
        TextToDate = vbNullString
    End If
End Function

'----------------------------------------------------
' Description:
'   Convert a given string into a valid time.
'
' Inputs:
'   SourceText = string to be converted to a time
'
' Returns:
'   TextToTime = Time value of the string
'----------------------------------------------------
Public Function TextToTime( _
    ByVal SourceText As String) As String

    If IsDate(SourceText) Then
        TextToTime = TimeValue(SourceText)
    Else
        TextToTime = vbNullString
    End If
End Function

--
John Tabor

http://members.bellatlantic.net/~jftabor
___________

Quote:

>This should be easy for most of you. I'm writing a simple, little VB5
>app. that adds two times together, using the DateAdd method. I simply
>want to know how to test the user's input (InputBox$) for whether or not
>they have entered a valid time (00:00:00 - 23:59:59). I'd like to trap
>the error and prompt the user with a MsgBox to tell them to do re-enter
>the time. I've got everything down but how to test the input for a valid
>time (date) format, e.g. "00:35:55". For the life of me, I can't figure
>it out. It's gotta be simple... Any help is GREATLY appreciated! THANKS,



Thu, 10 May 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Simple question, please help!

2. Simple question, Please Help!!! :)))

3. Simple question...please help

4. A simple question - please help

5. Simple Question, Please help!!! :)))

6. Simple question, please help?!

7. MDI simple questions - please help

8. Simple question, please help!

9. Simple question - please help me arghhh!!!!!!!!

10. SIMPLE SIMPLE ListView Question. Please help

11. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

12. SIMPLE QUESTION, please SIMPLE ANSWER

 

 
Powered by phpBB® Forum Software