
假设你的表格结构如下
A B C
被抽项目 抽选序号 随机抽中
ase123 5 158ves
dfgt464
ds454
da356
hynh232
ahrt679
158ves
421gfg
kuy3545
412ghj
请在C2单元格输入公式:=INDEX(A:A,ROUND(RAND()(COUNTA(A:A)-1),0)+1),
现在只需在B2单元格输入抽选序号,再回车C2单元格就会显示出被随机选中的项目,
其中A列的被抽项目数无限制。
Dim A() As String
Private Sub BEG_Click()
Timer1Enabled = True
If BEGCaption = "开始抽签" Then
BEGCaption = "停止"
Else
BEGCaption = "开始抽签"
Timer1Enabled = False
End If
End Sub
Private Sub ADD_Click()
Dim STR As String
STR = InputBox("请输入要增加的名字")
Dim conn As New ADODBConnection
Dim rs As New ADODBRecordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1 = "Provider=MicrosoftJetOLEDB40;"
Str2 = "Data Source=C:\Documents and Settings\Administrator\桌面\DB2MDB;"
Str3 = "Jet OLEDB:Database Password="
connOpen Str1 & Str2 & Str3
strSQL = "select from 表1 "
rsOpen strSQL, conn, 3, 3
rsAddNew
rs!名字 = STR
rsUpdate
rsClose
connClose
End Sub
Private Sub Form_Load()
Timer1Enabled = False
Dim conn As New ADODBConnection
Dim rs As New ADODBRecordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1 = "Provider=MicrosoftJetOLEDB40;"
Str2 = "Data Source=C:\Documents and Settings\Administrator\桌面\DB2MDB;"
Str3 = "Jet OLEDB:Database Password="
connOpen Str1 & Str2 & Str3
strSQL = "select from 表1 "
rsOpen strSQL, conn, 3, 3
TEM = rsRecordCount
rsClose
For I = 1 To TEM
strSQL = "select from 表1 where 编号=" & I & ""
rsOpen strSQL, conn, 3, 3
ReDim Preserve A(0 To I)
A(I) = rs!名字
rsClose
Next I
connClose
End Sub
Private Sub Timer1_Timer()
Static J As Integer
Text1Text = A(J)
J = J + 1
If J = UBound(A) Then
J = 1
End If
End Sub
代码以及运行过,你现在桌面上建立一个名为db2的数据库,一个字段“名字”
以上就是关于我想做一个的随机抽签程序 ,用PPT,EXCEL做都可以,指定任意多个单元格内容为等概率随机抽出的内容全部的内容,包括:我想做一个的随机抽签程序 ,用PPT,EXCEL做都可以,指定任意多个单元格内容为等概率随机抽出的内容、求一个抽签的VB程序,能把名字写入数据库,又能运行抽签 源代码请发cht3068@sina.com、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)