Sub TestTrains()
Dim i As Integer
Dim vTimes As Variant
Dim dDep As Date
Dim sStr As String
vTimes = Array(9, "Paddington", 0, "Reading", 26, "Swindon", 56, "Chippenham", 73, "Bath Spa", 85)
dDep = Format(InputBox("What time to depart " & vTimes(1), "Departure"), "hh:mm")
sStr = ""
For i = 1 To vTimes(0) Step 2
sStr = sStr & vTimes(i) & " (" & TimeValue(dDep + (vTimes(i + 1))) & ") "
Next i
MsgBox (sStr)
End Sub
|