Hi all
Last week I have made my first function. It works fine but needs fine tuning.
My code looks like:
Function SchaatsSeizoen(Time As Variant, Distance As Variant) As Variant
Dim Minutes As Variant
Dim Seconds As Variant
Dim Hundredths As Variant
' When adding times, the character that divides Minutes from Seconds and Second from 1/100 can
' be e.g. , . : or any other character.
' To prevent error messages from happening, can these characters be captured in eg an array?
' like Dim myarray As Variant
' myarray = Array(",", ".", ":")
' then the line where the layout is detemined would be eg "#" & myArray & "##" & myArray & "##"
If Time.Value Like "##" Then
Minutes = 0
Seconds = Time
Hundredths = 0
Call TimeToPoints(Minutes, Seconds, Hundredths, Distance)
SchaatsSeizoen = Round(Left(TimeToPoints(Minutes, Seconds, Hundredths, Distance), 6), 3)
ElseIf Time.Value Like "#.##.##" Then
Minutes = 0
Seconds = Left(Time, 2)
Hundredths = Right(Time, 1) * 10 ' multiplied with 10 since this time is in 1/10, and not in 1/100
Call TimeToPoints(Minutes, Seconds, Hundredths, Distance)
SchaatsSeizoen = Round(Left(TimeToPoints(Minutes, Seconds, Hundredths, Distance), 6), 3)
Basically my question is in this code.
Is the solution I am thinking of is making any sense, or is there a different, better to get to what I want?
Thanks in advance
Hein
Bookmarks