minutes & seconds functions

R

Robert Crandal

Does VBA have any built in functions that test if a
string is properly formatted in minutes and seconds
notation such as: mm:ss???

For example, if the function is given a string value
of "1:22" or "0:22" or ":45", then the function should
return TRUE! However, the function would return
false if it was given strings such as: "6a:20" or "hello" etc...

thnx
 
R

Rob van Gelder

Use the IsDate function

However, you'll note that ":45" is not considered a valid date.

Sub test()
Debug.Print IsDate("1:22")
Debug.Print IsDate("0:22")
Debug.Print IsDate(":45")
Debug.Print IsDate("6a:20")
Debug.Print IsDate("hello")
End Sub

Cheers,
Rob
 
R

Robert Crandal

Are there a family of functions related to "IsDate" which
extract minutes and seconds???

For example:

GetMinutes("22:42") == would return "22"
GetSeconds("13:01") == would return "01"
 
R

Rob van Gelder

Sub test()
Debug.Print Minute("00:22:42")
Debug.Print Second("00:13:01")
End Sub

note that 22:42 would be interpreted as 10pm, not 22 minutes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top