PrInCeSs Of MuSiC
Genius
1 min. di lettura
Vota 5 / 5

Concetti Chiave

  • Il programma genera casualmente una base, un logaritmo e un argomento esponenziale per un quiz matematico.
  • La funzione GENERA_Numeri genera i numeri casuali e aggiorna i campi di testo corrispondenti.
  • Il pulsante "Rigenera" permette di generare nuovi numeri casuali, ripulendo i campi di testo precedenti.
  • La funzione Pulisci ripristina i campi di testo e nasconde l'etichetta del risultato.
  • Il pulsante "Verifica" controlla la correttezza della risposta inserita, mostrando un messaggio di esito.
Indovina il logaritmo!
Codice:

Public Class FrmEspLog
Dim base, logaritmo, numero As Integer
Dim argomento As Single

Private Sub FrmEspLog_Load(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call GENERA_Numeri()
End Sub
Public Sub GENERA_Numeri()
Call Pulisci()
numero = Int(Rnd() * 3) + 1
Select Case numero
Case 1
base = Int(Rnd() * 3) + 1
logaritmo = Int(Rnd() * 7) - 3
argomento = base ^ logaritmo
Txtesponente.Text = logaritmo
TxtArgomento.Text = argomento
Case 2
base = Int(Rnd() * 3) + 1
logaritmo = Int(Rnd() * 7) - 3
argomento = base ^ logaritmo
Txtbase.Text = base
Txtesponente.Text = logaritmo
Case 3
base = Int(Rnd() * 3) + 1
logaritmo = Int(Rnd() * 7) - 3
argomento = base ^ logaritmo
Txtbase.Text = base
TxtArgomento.Text = argomento
End Select
End Sub

Private Sub BtnRigenera_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRigenera.Click
Call GENERA_Numeri()
End Sub

Public Sub Pulisci()
lblesito.Text = ""
lblesito.Visible = False
Txtbase.Text = ""
TxtArgomento.Text = ""
Txtesponente.Text = ""
End Sub

Private Sub BtnVerifica_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnVerifica.Click
If TxtArgomento.Text = argomento And Txtbase.Text = base And Txtesponente.Text = logaritmo And _
TxtArgomento.Text <> "" And Txtbase.Text <> "" And Txtesponente.Text <> "" Then
lblesito.Visible = True
lblesito.Text = "Complimenti!"
Else
lblesito.Visible = True
lblesito.Text = "Attento, la soluzione giusta è log in base " & base & " di " & argomento & " = " & logaritmo
End If

End Sub
End Class

Domande e risposte

Hai bisogno di aiuto?
Chiedi alla community