【发布时间】:2014-06-24 12:25:46
【问题描述】:
基本上我需要将此 Visual Basic 代码翻译成 Basic4Android 代码。 我想要做的是从 1-15 随机分配 16 个按钮值和一个空值。每次他们都会有所不同。我已经在 VB 中完成了它并且它可以工作,但我知道我想在 Android 上制作它。
Sub Shuffle()
Dim a(15), i, j, RN As Integer
Dim flag As Boolean
flag = False
i = 1
a(j) = 1
Do While i <= 15
Randomize()
RN = CInt(Int((15 * Rnd()) + 1))
For j = 1 To i
If (a(j) = RN) Then
flag = True
Exit For
End If
Next
If flag = True Then
flag = False
Else
a(i) = RN
i = i + 1
End If
Loop
Form1.Button1.Text = a(1)
Form1.Button2.Text = a(2)
Form1.Button3.Text = a(3)
Form1.Button4.Text = a(4)
Form1.Button5.Text = a(5)
Form1.Button6.Text = a(6)
Form1.Button7.Text = a(7)
Form1.Button8.Text = a(8)
Form1.Button9.Text = a(9)
Form1.Button10.Text = a(10)
Form1.Button11.Text = a(11)
Form1.Button12.Text = a(12)
Form1.Button13.Text = a(13)
Form1.Button14.Text = a(14)
Form1.Button15.Text = a(15)
Form1.Button16.Text = ""
End Sub
我只知道将“Integer”更改为“Int”并删除所有“Form1”。我不能使用 Randomize() 或 CInt 或 Int 语句,因为它们会给我错误。
【问题讨论】:
标签: basic basic4android