Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. Dim tallinn_time As Date
  4. Dim stocholm_time As Date
  5. Dim tallinn_departure As Date
  6. Dim stocholm_departure As Date
  7. Dim tallinn_arrival As Date
  8. Dim stocholm_arrival As Date
  9. Dim tspeed, sspeed As Integer
  10. Const a = 5, b = 10, c = 15
  11. Dim linenr As Integer
  12. Dim both_arrived As Boolean
  13.  
  14. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  15.  
  16. Const fname$ = "departure_time.txt"
  17. If System.IO.File.Exists(fname) = True Then
  18. Dim objReader As New System.IO.StreamReader(fname)
  19.  
  20. Dim TextLine As String = ""
  21. Do While objReader.Peek() <> -1
  22. TextLine = ""
  23. TextLine = TextLine & objReader.ReadLine() & vbNewLine
  24. If linenr = 0 Then
  25. 'Label4.Text = Microsoft.VisualBasic.Left(TextLine, 5)
  26. tallinn_departure = Microsoft.VisualBasic.Left(TextLine, 5) & ":00 PM"
  27. ElseIf linenr = 1 Then
  28. 'Label2.Text = Microsoft.VisualBasic.Left(TextLine, 5)
  29. stocholm_departure = Microsoft.VisualBasic.Left(TextLine, 5) & ":00 PM"
  30. End If
  31. linenr = linenr + 1
  32. Loop
  33.  
  34. objReader.Close()
  35. Else
  36. MsgBox("File Does Not Exist")
  37. End If
  38. 'aga ta ju ei loe seda faili :( v nagu millal ja kuidas ma panen selle, et ta selle järgi hakkaks liikuma? see laev
  39.  
  40. both_arrived = False
  41. Timer1.Start()
  42.  
  43. tspeed = -Int(Rnd() * (c - b + 1) + b)
  44. sspeed = Int(Rnd() * (b - a + 1) + a)
  45. 'mulle külle ei tundu, et ta randomilt oleks valinud kiirused. aga no, mingi mõte vähemalt :D
  46.  
  47. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipY)
  48. Label5.Visible = False
  49. Label6.Visible = False
  50. Label7.Visible = False
  51. Label8.Visible = False
  52.  
  53. tallinn_time = "14:00:00 PM"
  54. Label4.Text = Format(tallinn_time, "HH:mm")
  55. stocholm_time = "13:00:00 PM"
  56. Label2.Text = Format(stocholm_time, "HH:mm")
  57.  
  58.  
  59.  
  60.  
  61. End Sub
  62.  
  63. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  64.  
  65. tallinn_time = tallinn_time.AddMinutes(1)
  66. stocholm_time = stocholm_time.AddMinutes(1)
  67. Label2.Text = Format(stocholm_time, "HH:mm")
  68. Label4.Text = Format(tallinn_time, "HH:mm")
  69.  
  70. If (PictureBox1.Right > Me.ClientSize.Width) Then
  71. If (sspeed > tspeed) Then
  72. both_arrived = True
  73. End If
  74. Label5.Visible = True
  75. Label6.Visible = True
  76. Label6.Text = Format(stocholm_arrival, "HH:mm")
  77. Else
  78. If (stocholm_time >= stocholm_departure) Then
  79. PictureBox1.Left = PictureBox1.Left + sspeed
  80. End If
  81. stocholm_arrival = stocholm_time
  82. End If
  83.  
  84. If (PictureBox2.Left <= 0) Then
  85. If (tspeed > sspeed) Then
  86. both_arrived = True
  87. End If
  88. Label7.Visible = True
  89. Label8.Visible = True
  90. Label8.Text = Format(tallinn_arrival, "HH:mm")
  91. Else
  92. If tallinn_time >= tallinn_departure Then
  93. PictureBox2.Left = PictureBox2.Left + tspeed
  94. End If
  95. tallinn_arrival = tallinn_time
  96. End If
  97.  
  98. If both_arrived Then
  99. Timer1.Stop()
  100. MsgBox("Laevad on sadamas ilusti")
  101. End If
  102.  
  103. End Sub
  104. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement