https://www.myziyuan.com/
- hedianshui
- Dim n As IntegerDim a()Private Sub Command1_Click() If n = 0 Then '第一次点击时执行 m = Val(Text1) ReDim a(1 To m) For i = 1 To m '生成数组a,元素为1至m这m个数 a(i) = i Next For i = 1 To m - 1 '随机打乱数组a中元素 r = Int(Rnd * m + 1) tmp = a(i) a(i) = a(r) a(r) = tmp Next End If n = n + 1 '计数点击次数 If n > Val(Text1) Then '次数超e69da5e887aae79fa5e9819331333337373666过指定次数,抽奖结束 MsgBox "抽奖结束!" Exit Sub End If Text2 = a(n) '从数组中抽出第n个数,由于数组中是随机排列,所以相当于生成一个随机数,并且不会重复End Sub
- 2021-03-26 14:45:02
- hedianshui
- 完化楼上的,,可以摇人名,,不会出现重复,,不会出现空白加一个LIST 和一个TIMER ,COMMANDDim a(30) As StringPrivate Sub Command1_Click()If Command1.Caption = "开始" Thena(1) = "姓名1"a(2) = "姓名2"a(3) = "姓名3"a(4) = "姓名4"a(5) = "姓名5"a(6) = "姓名6"a(7) = "姓名7"a(8) = "姓名8"a(9) = "姓名9"a(10) = "姓名10"a(11) = "姓名11"a(12) = "姓名12"a(13) = "姓名13"a(14) = "姓名14"a(15) = "姓名15"a(16) = "姓名16"a(17) = "姓名17"a(18) = "姓名18"a(19) = "姓名19"a(20) = "姓名20"a(21) = "姓名21"a(22) = "姓名22"a(23) = "姓名23"a(24) = "姓名24"a(25) = "姓名25"a(26) = "姓名26"a(27) = "姓名27"a(28) = "姓名28"a(29) = "姓名29"a(30) = "姓名30"Command1.Caption = "停止"Timer1.Enabled = TrueTimer1.Interval = 50ElseTimer1.Enabled = FalseTimer1.Interval = 0Command1.Caption = "开始"End IfEnd SubPrivate Sub Form_Load()Command1.Caption = "开始"End SubPrivate Sub Timer1_Timer()List1.ClearDim b(7) As DoubleFor i = 1 To 7Randomize1b(i) = Int(29 * Rnd + 1)For j = 1 To i - 1If b(i) = b(j) Then GoTo 1Next jList1.AddItem a(b(i))Next iEnd Sub
- 2021-02-12 15:39:24
- 好牛通
- 简易抽奖程序怎么做,我不知道你用什么语言去写程序的,所以不能给具体的代码,只能给个思路吧。方法有两种 当然先是建立一个数组把所有输入的QQ号保存起来一种是利用随机函数生成的结果,去抽数组决定抽奖结果另一种也是利用随机函数,不过是生成区间,用不同的区间来决定不同的奖励。
- 2021-02-12 15:39:24