OutputVar := MfTimeSpan.TryParse(result, s)
Static Method.
Converts the string representation of a time interval to its MfTimeSpan equivalent and returns a value that indicates whether the conversion succeeded.
result
When this method returns, contains an object that represents the time interval specified by s, or Zero if the conversion failed.
s
A string that specifies the time interval to convert.
Can be instance of MfString or var containing string.
Static Method.
Returns true if s was converted successfully; Otherwise, false. This operation returns false if the s parameter is null, has an invalid format, represents a time interval that is less than MinValue or greater than MaxValue, or has at least one days, hours, minutes, or seconds component outside its valid range.
The TryParse method is like the Parse() method, except that it does not throw an exception if the conversion fails.
Throws MfInvalidOperationException if not called as a static method.
str := new MfString("7")
span := new MfTimeSpan()
if (MfTimeSpan.TryParse(span, str))
{
MsgBox % span.ToString() ; Displays: 07.00:00:00
} else {
MsgBox Unable to parse value
}
str.Value := "7:14"
if (MfTimeSpan.TryParse(span, str)) {
MsgBox % span.ToString() ; Displays: 07:14:00
} else {
MsgBox Unable to parse value
}
if (MfTimeSpan.TryParse(span, "7.14:17")) {
MsgBox % span.ToString() ; Displays: 07:14:17:00
} else {
MsgBox Unable to parse value
}
if (MfTimeSpan.TryParse(span, "7.14:17:41")) {
MsgBox % span.ToString() ; Displays: 07.14:17:41
} else {
MsgBox Unable to parse value
}
if (MfTimeSpan.TryParse(span, "7.14:17:41.2434")) {
MsgBox % span.ToString() ; Displays: 07.14:17:41.2434000
} else {
MsgBox Unable to parse value
}
if (MfTimeSpan.TryParse(span, "5.14:17:41.023")) {
MsgBox % span.ToString() ; Displays: 05.14:17:41.0230000
} else {
MsgBox Unable to parse value
}