Advertisement
Tony041010

Noaa

Jul 7th, 2021
478
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '第一題、展開10*10的雷達陣列
  2. Private Sub Command4_Click()
  3.     Randomize
  4.     For i = 1 To 99
  5.         Load Image1(i)
  6.         Load Label1(i)
  7.         If i Mod 10 = 0 Then '向上對齊
  8.            Label1(i).Left = Label1(i - 10).Left
  9.             Label1(i).Top = Label1(i - 10).Top + Image1(i - 10).Height
  10.             Image1(i).Left = Image1(i - 10).Left
  11.             Image1(i).Top = Image1(i - 10).Top + Image1(i - 10).Height
  12.         Else '向左對齊
  13.            Label1(i).Left = Label1(i - 1).Left + Image1(i - 1).Width
  14.             Label1(i).Top = Label1(i - 1).Top
  15.             Image1(i).Left = Image1(i - 1).Left + Image1(i - 1).Width
  16.             Image1(i).Top = Image1(i - 1).Top
  17.         End If
  18.         Label1(i).Caption = Format(15 - Rnd * 20, "00.00")
  19.         Label1(i).ZOrder vbBringToFront
  20.         Label1(i).BackStyle = 0
  21.         Label1(i).ForeColor = vbWhite
  22.         Label1(i).Visible = True
  23.         Image1(i) = LoadPicture("1.jpg")
  24.         Image1(i).Visible = True
  25.        
  26.     Next
  27.     Label1(0).Caption = Format(15 - Rnd * 20, "00.00")
  28. End Sub
  29. '第二題、找出最大者
  30. Private Sub Command1_Click()
  31.     m = 0
  32.     m_index = 0
  33.     For i = 0 To 99
  34.         If Label1(i).Caption > m Then
  35.             m = Label1(i)
  36.             m_index = i
  37.         End If
  38.     Next
  39.     Image1(m_index).Picture = LoadPicture("3.jpg")
  40.     Image1(m_index).Tag = "1"
  41.    
  42. End Sub
  43. '第三題,找出前三大者
  44. Private Sub Command2_Click()
  45.     m = 0
  46.     m_index = 0
  47.     For i = 0 To 99
  48.         If Label1(i).Caption > m Then
  49.             m = Label1(i)
  50.             m_index = i
  51.         End If
  52.     Next
  53.     Image1(m_index).Picture = LoadPicture("3.jpg")
  54.     Image1(m_index).Tag = "1"
  55.     n = 0
  56.     n_index = 0
  57.     For i = 0 To 99
  58.         If Label1(i).Caption > n And Image1(i).Tag <> "1" Then
  59.             n = Label1(i)
  60.             n_index = i
  61.         End If
  62.     Next
  63.     Image1(n_index).Picture = LoadPicture("3.jpg")
  64.     Image1(n_index).Tag = "2"
  65.     o = 0
  66.     o_index = 0
  67.     For i = 0 To 99
  68.         If Label1(i).Caption > o And Image1(i).Tag <> "1" And Image1(i).Tag <> "2" Then
  69.             o = Label1(i)
  70.             o_index = i
  71.         End If
  72.     Next
  73.     Image1(o_index).Picture = LoadPicture("3.jpg")
  74.     Image1(o_index).Tag = "3"
  75. End Sub
  76.  
  77. '第四題,用亂數模擬noaa雷達數值並追蹤太空船的位置
  78. Private Sub Command3_Click()
  79.     Timer1.Interval = 1000
  80. End Sub
  81.  
  82. Private Sub Timer1_Timer()
  83.     Randomize
  84.     For i = 0 To 99
  85.         Label1(i).Caption = Format(15 - Rnd * 20, "00.00")
  86.         Image1(i).Picture = LoadPicture("1.jpg")
  87.         Image1(i).Tag = ""
  88.     Next
  89.         Command2_Click
  90. End Sub
  91.  
Advertisement
RAW Paste Data Copied
Advertisement