如何在vb的同一个text文本框中随机显示不同的句子
如点击Command1随机text1显示“上”“下”“左”“右”如果加同时text2显示“前”“后”“左”“右”怎么办?...
如点击Command1随机text1显示“上”“下”“左”“右”
如果加同时text2显示“前”“后”“左”“右”怎么办? 展开
如果加同时text2显示“前”“后”“左”“右”怎么办? 展开
4个回答
展开全部
dim a(3)
Private Sub Command1_click()
dim b as integer
a(0) = "上"
a(1) = "下"
a(2) = "左"
a(3) = "右"
Randomize
b=int(4 * Rnd) '取得0-3的随机数
Text1.Text = a(b)
End Sub
Private Sub Command1_click()
dim b as integer
a(0) = "上"
a(1) = "下"
a(2) = "左"
a(3) = "右"
Randomize
b=int(4 * Rnd) '取得0-3的随机数
Text1.Text = a(b)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim i As Integer
Dim tmpStr(3) As String
'数组赋值
tmpStr(0) = "上"
tmpStr(1) = "下"
tmpStr(2) = "左"
tmpStr(3) = "右"
Randomize
i = Int(Rnd * 4)
Text1.Text = tmpStr(i)
Dim tmpStr(3) As String
'数组赋值
tmpStr(0) = "上"
tmpStr(1) = "下"
tmpStr(2) = "左"
tmpStr(3) = "右"
Randomize
i = Int(Rnd * 4)
Text1.Text = tmpStr(i)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_click()
temp = Array("上", "下", "左", "右")
temp2= Array("前", "后", "左", "右")
Randomize
x=Int(Rnd * (UBound(temp) + 1)))
Text1.Text = temp(x)
Text2.Text = temp2(x)
End Sub
temp = Array("上", "下", "左", "右")
temp2= Array("前", "后", "左", "右")
Randomize
x=Int(Rnd * (UBound(temp) + 1)))
Text1.Text = temp(x)
Text2.Text = temp2(x)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询