Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Memory - Form1.frm

Form1.frm

Caricato da: Albertking82
Scarica il programma completo

  1. Const h = 7350
  2. Dim i As Integer, j As Integer
  3. Public lev As Integer, f As Boolean
  4. Dim numb As Integer, col As Integer
  5. Dim cresc As Integer
  6. Sub sort(m As Integer)
  7.  
  8.  Dim temp As Integer
  9.  
  10.  For i = 0 To m - 1
  11.   For j = i + 1 To m - 1
  12.  
  13.    If v(i) > v(j) Then
  14.     temp = v(i)
  15.     v(i) = v(j)
  16.     v(j) = temp
  17.    End If
  18.  
  19.   Next j
  20.  Next i
  21.  
  22.  
  23. End Sub
  24. Sub number(num As Integer)
  25.  
  26.  For i = 0 To num - 1
  27.  
  28.   f = False
  29.   Randomize
  30.   numb = Int(Rnd * 13) + 1
  31.   col = Int(Rnd * 13) + 1
  32.    For j = 0 To i
  33.    
  34.       If numb = v(j) Then
  35.      
  36.        f = True
  37.        i = i - 1
  38.      
  39.       End If
  40.      
  41.    Next j
  42.    
  43.     If Not f Then
  44.       v(i) = numb
  45.       Text1(i).ForeColor = QBColor(col)
  46.       Text1(i).Text = v(i)
  47.     End If
  48.  Next i
  49.  
  50.   For i = 0 To lev - 1
  51.     v(i) = Text1(i).Text
  52.     vett(i) = v(i)
  53.   Next i
  54.  
  55.   Call sort(lev)
  56.   Timer1.Enabled = True
  57.  
  58. End Sub
  59.  
  60. Sub level(n As Integer)
  61.  
  62.  For i = 0 To n - 1
  63.  
  64.    Text1(i).Visible = True
  65.  
  66.  Next i
  67.  
  68.  Call number(n)
  69.  
  70. End Sub
  71.  
  72. Private Sub cmdc_Click()
  73.  
  74.  
  75.  For i = 0 To lev - 2
  76.  
  77.   If Text1(i).Text = "" Then
  78.   Exit Sub
  79.  
  80.   End If
  81.  
  82.  Next i
  83.  
  84.  cmdc.Visible = False
  85.  
  86.  For i = 0 To lev - 2
  87.  
  88.   cresc = CInt(Text1(i).Text)
  89.  
  90.  If cresc <> v(i) Then
  91.  
  92.    lblstart.Caption = "La sequenza non è esatta"
  93.    Form2.Show
  94.    MsgBox "HAI PERSO", vbInformation, "GAME OVER"
  95.    cmdgo.Visible = True
  96.    lblstart.Caption = "Memorizza e poi ordina in modo crescente"
  97.    Call Form_Load
  98.    Exit Sub
  99.    
  100.  End If
  101.  
  102.  Next i
  103.  
  104.   lblstart.Caption = "La sequenza è esatta"
  105.   Timer2.Enabled = True
  106.  
  107.  
  108. End Sub
  109.  
  110. Private Sub cmdgo_Click()
  111.  
  112.  Unload Form2
  113.  Form1.Height = h
  114.  cmdgo.Visible = False
  115.  Call level(lev)
  116.  
  117.   If lev < 12 Then
  118.  
  119.     lev = lev + 1
  120.    
  121.   End If
  122.  
  123. End Sub
  124. Private Sub Form_Load()
  125.  
  126.  f = False
  127.  lev = 2
  128.  
  129.  For i = 0 To 12
  130.      Text1(i).Text = ""
  131.      Text1(i).Visible = False
  132.  Next i
  133.  
  134. End Sub
  135.  
  136. Private Sub Text1_Change(Index As Integer)
  137.  
  138.  If Not IsNumeric(Text1(Index).Text) Then
  139.     Text1(Index).Text = ""
  140.    
  141.  End If
  142.  
  143. End Sub
  144.  
  145. Private Sub Timer1_Timer()
  146.  
  147.  For i = 0 To lev - 1
  148.      Text1(i).Text = ""
  149.  Next i
  150.  cmdc.Visible = True
  151.  Timer1.Enabled = False
  152.  
  153. End Sub
  154.  
  155. Private Sub Timer2_Timer()
  156.  
  157.  Call cmdgo_Click
  158.  Timer2.Enabled = False
  159.  
  160. End Sub