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
Calcolo 10 - Form1.frm

Form1.frm

Caricato da: Albertking82
Scarica il programma completo

  1. Dim p As String
  2. Dim i As Integer
  3. Dim num As Integer, num2 As Integer
  4. Dim op As Integer, ris As Integer
  5. Dim temp As Integer, errore As Integer
  6. Dim t As Integer, tempo As Single
  7.  
  8.  
  9. Private Sub cmdgo_Click()
  10.  
  11.  cmdrec.Visible = False
  12.  Timer1.Enabled = True
  13.  i = i + 1
  14.  lblop.Visible = True
  15.  txtris.Visible = True
  16.  cmdok.Visible = True
  17.  cmdgo.Visible = False
  18.  Randomize
  19.  num = Int(Rnd * 9)
  20.  op = Int(Rnd * 3) + 1
  21.  num2 = Int(Rnd * 10)
  22.  
  23.    Select Case op
  24.    
  25.     Case 1
  26.    
  27.      lblop.Caption = num & " + " & num2 & " = "
  28.      ris = num + num2
  29.      
  30.     Case 2
  31.    
  32.      If num < num2 Then
  33.      
  34.         temp = num
  35.         num = num2
  36.         num2 = temp
  37.        
  38.      End If
  39.      
  40.      lblop.Caption = num & " - " & num2 & " = "
  41.      ris = num - num2
  42.      
  43.     Case 3
  44.    
  45.      lblop.Caption = num & " x " & num2 & " = "
  46.      ris = num * num2
  47.      
  48.     ' Case 4
  49.      'lblop.Caption = num & " : " & num2 & " = "
  50.      
  51.    End Select
  52.  
  53.  
  54. End Sub
  55.  
  56.  
  57. Private Sub cmdok_Click()
  58.  
  59.  If Int(txtris.Text) <> ris Then
  60.       errore = errore + 1
  61.       lblerr.Caption = "Errori : " & errore
  62.    End If
  63.  
  64.  If i >= 10 Then
  65.   tempo = t / 100
  66.   tempo = tempo + errore
  67.   MsgBox "Hai totalizzato " & errore & " errori" _
  68.   & vbCrLf & "Tempo totalizzato : " & tempo & " secondi", vbInformation, "Game over"
  69.   cmdrec.Visible = True
  70.   Timer1.Enabled = False
  71.   t = 0
  72.   Call Form_Load
  73.   Exit Sub
  74.  End If
  75.  
  76.  cmdok.Visible = False
  77.  lblop.Caption = ""
  78.  txtris.Text = ""
  79.  txtris.Visible = False
  80.  Call cmdgo_Click
  81.      
  82. End Sub
  83.  
  84. Private Sub cmdrec_Click()
  85.  
  86.  Dim nome As String, tot As Single
  87.  nome = InputBox("Inserisci il tuo nome", "Nome record")
  88.  If nome = "" Then nome = "Sconosciuto"
  89.  Open p For Append As 1
  90.   Print #1, nome & " : " & tempo
  91.  Close #1
  92.  cmdrec.Visible = False
  93. End Sub
  94.  
  95. Private Sub Form_Load()
  96. i = 0
  97. cmdgo.Visible = True
  98. lblop.Caption = ""
  99. txtris.Text = ""
  100. txtris.Visible = False
  101. cmdok.Visible = False
  102. p = App.path & "\" & "record.dat"
  103. lblerr.Caption = "Errori : 0"
  104.  
  105. errore = 0
  106. End Sub
  107.  
  108. Private Sub Timer1_Timer()
  109. t = t + 1
  110. End Sub
  111.  
  112. Private Sub txtris_Change()
  113.  
  114.  If Not IsNumeric(txtris.Text) Then
  115.      txtris.Text = ""
  116.      cmdok.Enabled = False
  117.   Else
  118.      cmdok.Enabled = True
  119.  End If
  120.  
  121. End Sub
  122.  
  123. Private Sub txtris_KeyDown(KeyCode As Integer, Shift As Integer)
  124.  
  125. If KeyCode = 13 Then
  126.   Call cmdok_Click
  127. End If
  128.  
  129. End Sub