Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim arrText() As String
- #Region "Functions"
- Function check(ByVal result) 'Checking the result
- Select Case result
- Case result = NumericUpDown1.Value = False 'result isn't same as our chosen result
- Return False
- Case result = NumericUpDown1.Value = True 'result is same as our chosen result
- Return True
- End Select
- End Function
- Function count() 'counting the X
- Dim result As Double
- Dim MathStr As String = String.Empty
- Dim x As Integer
- For x = 0 To 1000 'Counting with numbers 0 to 1000
- For i As Integer = 0 To UBound(arrText)
- MathStr &= arrText(i) & If(i < UBound(arrText), "", x)
- Next
- result = New DataTable().Compute(MathStr, Nothing) 'Counting
- Select Case check(result) 'checking
- Case True 'if the result equals our chosen result
- Return x 'returns the lucky number
- Exit Function
- Case Else
- End Select
- Next
- Return True
- End Function
- #End Region
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- arrText = TextBox1.Text.Split("x")
- CheckForIllegalCrossThreadCalls = False
- Dim t As New Threading.Thread(AddressOf count)
- t.IsBackground = True
- t.Start()
- ListBox1.Items.Add(count())
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement