s1555
asked on
Random maths symbol into textbox
How can i make a random maths symbol, plus, minus, divide, multiply appear into a text box at the click of a button.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i liked roverm's style the best !! simple and does the work.. though could be more generalized
public sub printRandomChar()
Randomize()
dim chars as string = "+-/*"
txtBox.Text = Mid(chars, Int(Rnd() * chars.length) + 1, 1)
end sub
so .. now, all you'd have to do is change the value of chars, and you'd have to remember to change the max. value of string.
public sub printRandomChar()
Randomize()
dim chars as string = "+-/*"
txtBox.Text = Mid(chars, Int(Rnd() * chars.length) + 1, 1)
end sub
so .. now, all you'd have to do is change the value of chars, and you'd have to remember to change the max. value of string.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: roverm {http:#9858927}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
TheLearnedOne
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: roverm {http:#9858927}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
TheLearnedOne
EE Cleanup Volunteer
Private myHashTable As New HashTable
myHashTable.Add(0, "+")
myHashTable.Add(1, "-")
myHashTable.Add(2, "*")
myHashTable.Add(3, "/")
then in the buttonclick handler all you have to do is the following:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myRandomNumGen As New Random
MathSignText.Text = "" 'Clean up old value
MathSignText.Text = myHashTable(myRandomNumGen
End Sub
This should do it