vb.net中如何随机出现运算符“+”“-”“*”“/“
推荐于2017-09-25
展开全部
你可以换个思路嘛,随机数只能显示数字,但也可以转换为符号
Dim a
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
a = Int(Rnd() * 4) + 1
Select Case a
Case 1
TextBox1.Text = "+"
Case 2
TextBox1.Text = "-"
Case 3
TextBox1.Text = "*"
Case 4
TextBox1.Text = "/"
End Select。
Dim a
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
a = Int(Rnd() * 4) + 1
Select Case a
Case 1
TextBox1.Text = "+"
Case 2
TextBox1.Text = "-"
Case 3
TextBox1.Text = "*"
Case 4
TextBox1.Text = "/"
End Select。
展开全部
你可以换个思路嘛,随机数只能显示数字,但也可以转换为符号
Dim a
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
a = Int(Rnd() * 4) + 1
Select Case a
Case 1
TextBox1.Text = "+"
Case 2
TextBox1.Text = "-"
Case 3
TextBox1.Text = "*"
Case 4
TextBox1.Text = "/"
End Select
End Sub
懂了吧?
Dim a
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
a = Int(Rnd() * 4) + 1
Select Case a
Case 1
TextBox1.Text = "+"
Case 2
TextBox1.Text = "-"
Case 3
TextBox1.Text = "*"
Case 4
TextBox1.Text = "/"
End Select
End Sub
懂了吧?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用随机函数,当出现哪个数字,就代表哪种运算符。
好像不能直接随机出现的。
好像不能直接随机出现的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyRandom As New Random
Dim aa As Integer = 44
Do While aa = 44 Or aa = 46 Or aa = 48
aa = MyRandom.Next(42, 48)
Loop
TextBox1.Text = Chr(aa)
End Sub
Dim MyRandom As New Random
Dim aa As Integer = 44
Do While aa = 44 Or aa = 46 Or aa = 48
aa = MyRandom.Next(42, 48)
Loop
TextBox1.Text = Chr(aa)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询