Imports System.IO
Public Class Form1
Dim o As New List(Of String)
Dim numbers As New List(Of String)
Private Function gn() As String
Return numbers(Int(Rnd() * numbers.Count))
End Function
Private Function geno() As String
Return o(Int(Rnd() * o.Count))
End Function
Private Function geto() As String
Dim op As String = lblsec.Text
If op.ToString.ToLower.Contains("*") Then
Return "*"
ElseIf op.ToString.ToLower.Contains("-") Then
Return "-"
ElseIf op.ToString.ToLower.Contains("+") Then
Return "+"
Else
Return ""
End If
End Function
Private Sub res()
Select Case geto()
Case "*"
If Val(TextBox1.Text) = Val(lblsec.Text.Split("*")(0)) * Val(lblsec.Text.Split("*")(1)) Then
My.Computer.Audio.Play(My.Resources.thanks, AudioPlayMode.Background)
PictureBox1.Image = My.Resources.tru
Else
My.Computer.Audio.Play(My.Resources.wrong, AudioPlayMode.Background)
PictureBox1.Image = My.Resources.fal
End If
Case "-"
If Val(TextBox1.Text) = Val(lblsec.Text.Split("-")(0)) - Val(lblsec.Text.Split("-")(1)) Then
My.Computer.Audio.Play(My.Resources.thanks, AudioPlayMode.Background)
PictureBox1.Image = My.Resources.tru
Else
My.Computer.Audio.Play(My.Resources.wrong, AudioPlayMode.Background)
PictureBox1.Image = My.Resources.fal
End If
Case "+"
If Val(TextBox1.Text) = Val(lblsec.Text.Split("+")(0)) + Val(lblsec.Text.Split("+")(1)) Then
My.Computer.Audio.Play(My.Resources.thanks, AudioPlayMode.Background)
PictureBox1.Image = My.Resources.tru
Else
My.Computer.Audio.Play(My.Resources.wrong, AudioPlayMode.Background)
PictureBox1.Image = My.Resources.fal
End If
End Select
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
o.Add("*")
o.Add("-")
o.Add("+")
numbers.Add("0")
numbers.Add("1")
numbers.Add("2")
numbers.Add("3")
numbers.Add("4")
numbers.Add("5")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If lblsec.Text.Length > 2 Then
res()
End If
lblsec.Text = gn() & geno() & gn()
End Sub
End Class