关于ado.net 高手请进!

zxyfp 2006-12-06 09:04:10
最近公司要我做一个抽奖系统,我用 select top 1 * from tab1 order by newid() 这个语句很准,很好用,是真正的抽奖系统,可是电视台放的那种就是滚动记录的那种啊,当按下按钮时就停止滚动,并且当前记录就是中奖人,因为在滚动记录时速度很快,人为没有办法去选择谁中不中奖。 这种滚动记录已被大多数人接受了(其实这样的抽奖系统不标准),但现实这样感觉比较好,因为用上面的那条SQL语句时,一下子就选出了中奖者,大家会认为这样有人在做假。所以请大家想一个好办法,谢谢!!
滚动抽奖,谢谢!!

你们在学ado.net时,看的那些资料啊?
...全文
111 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
dlzhangln 2006-12-06
ado方面,看msdn就行,或者下本ado.net高级编程
回复
dlzhangln 2006-12-06
关于摇奖:
Option Explicit
Dim num1 As Integer
Dim num2 As String
Dim aa(1 To 4), bb(1 To 4) As String
Dim str1 As String
Dim st As Integer
Dim x, i, j As Integer
Private Sub Form_Load()
Me.BackColor = &H80FF80
Command1.Caption = "确定"
Command1.Enabled = False
Command2.Caption = "开始抽奖"
Command2.Enabled = False
Command3.Caption = "显示中奖号码"
Command3.Enabled = False
Command4.Caption = "退出"
Me.Caption = "随机中奖"
Me.AutoRedraw = True
Label1.Caption = "请输入您的号码:"
Label1.FontSize = 12
Label1.BackStyle = 0
Label2.Caption = ""
Label2.FontSize = 30
Label2.ForeColor = &HFF
Label2.BackStyle = 0
Label3.Caption = ""
Label3.FontSize = 20
Label3.BackStyle = 0
Text1.Text = ""
Text1.FontSize = 24
Text1.MaxLength = 4
Timer1.Enabled = False
Timer1.Interval = 1
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Me
End
End Sub

Private Sub Command1_Click()
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = True
Label3.Caption = ""
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
If Len(Text1.Text) = 4 Then
str1 = Text1.Text
ElseIf Len(Text1.Text) >= 3 Then
str1 = "0" & Text1.Text
ElseIf Len(Text1.Text) >= 2 Then
str1 = "00" & Text1.Text
ElseIf Len(Text1.Text) >= 1 Then
str1 = "000" & Text1.Text
End If
Label3.Caption = "你的号码中的是" & getdat(str1, Label2.Caption) & "等奖!"
End Sub
Private Sub Command4_Click()
Unload Me
End
End Sub

Private Sub Text1_Change()
If Val(Text1.Text) <= 1000 And Val(Text1.Text) >= 1 Then
Command1.Enabled = True
End If
End Sub

Private Sub Timer1_Timer()
Label2.Caption = ""
Randomize
num1 = Int(Rnd * (1000 - 1 + 1) + 1)
Call todat(num1, num2)
Label2.Caption = num2
End Sub

Private Sub todat(numx As Integer, numy As String)
If numx >= 1000 Then
numy = 1000
ElseIf numx >= 100 Then
numy = "0" & numx
ElseIf numx >= 10 Then
numy = "00" & numx
ElseIf numx >= 1 Then
numy = "000" & numx
End If
End Sub
Private Function getdat(s1 As String, s2 As String)
'前三位数字全相适为1%,
'第四位相适的几率为5%,
'其中两个位置都相适为15%-5%=10%
'其中一个位置相适的几率为1/3-5%=29%,可以算作是34%
For i = 1 To 4
aa(i) = Mid$(s1, i, 1)
bb(i) = Mid$(s2, i, 1)
Next i
If aa(1) = "1" And bb(1) = "1" Then '1%的几率
x = 1
ElseIf aa(2) = bb(2) And aa(3) = bb(3) Then
x = 1
ElseIf aa(4) = bb(4) Then '5%的几率
x = 2
ElseIf aa(2) = bb(2) And aa(4) = bb(4) Then '大概是10%的几率
x = 3
ElseIf aa(3) = bb(3) And aa(4) = bb(4) Then
x = 3
ElseIf aa(2) = bb(2) Or aa(3) = bb(3) Then '大概是1/3的几率,也就是34%
x = 4
ElseIf aa(2) = bb(3) Or aa(2) = bb(4) Then '比1/3的几率多,大概是50%
x = 5
ElseIf aa(3) = bb(2) Or aa(3) = bb(4) Then
x = 5
ElseIf aa(4) = bb(2) Or aa(4) = bb(3) Then
x = 5
Else
x = 0
End If
getdat = x
End Function
回复
相关推荐
发帖
VB
创建于2007-09-28

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
申请成为版主
帖子事件
创建了帖子
2006-12-06 09:04
社区公告
暂无公告