吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5762|回复: 12
收起左侧

[其他原创] VB6.0写的年会抽奖程序

  [复制链接]
huangjie_52pj 发表于 2020-11-13 11:40
去年年会给公司写的抽奖小程序,请大家多多指导
链接:https://pan.baidu.com/s/1gvh-Tdsd7AydMI0YKfcBwA 提取码:a6o7




1.主页面

2.代码部分

[Visual Basic] 纯文本查看 复制代码
Dim ArrMan()Dim ArrMan1()
Dim t As Long
Dim StartCount As Long

Dim AwardType As String
Dim AwardCount As Integer

Dim ArrName() As String
Dim ArrRndNo() As Long

Dim strTitle As String

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

'MsgBox KeyCode


'''esc退出
'If KeyCode = 27 Then Unload Me


'''空格开始结束抽奖
If KeyCode = 32 And lbl_award.Caption <> "幸运奖" Then
    If StartCount = 0 Then
        StartCount = StartCount + 1
        StartAward
    Else
        StartCount = 0
        EndAward
    End If
    
End If


End Sub


'Sub InitUI()
'
'
'lblGongsi.Top = 1000
'lblGongsi.Left = Me.Width / 2 - lblGongsi.Width / 2 + img_logo.Width / 2
'
''Screen.Width
'
'
'lblTitle.Top = 2500
'lblTitle.Left = Me.Width / 2
'
'
'lbl_award.Top = 4000
'lbl_award.Left = Me.Width / 2 + lbl_award.Width / 6
'
'
'img_award.Top = Me.Height - img_award.Height / 2
'img_award.Left = Me.Width - img_award.Width / 2
'
'
'img_logo.Top = 1
'img_logo.Left = 1
'
'
'img_award.Visible = False
'lbl_award.Visible = False
'
'
'lbl_name(0).Visible = False
'
'
'
'Label1.Top = Me.Height + 2000
'Label1.Left = 1
'Label1.ForeColor = vbWhite 'RGB(119, 203, 231)
''Label1.ForeColor = RGB(119, 203, 231)
'
'Loadlbl_name 15
'
'
'
'End Sub


Sub InitUI()


lblGongsi.Top = 1000
lblGongsi.Left = Screen.Width / 2 - lblGongsi.Width / 2


lblTitle.Top = 2500
lblTitle.Left = Screen.Width / 2 - lblTitle.Width / 2


lbl_award.Top = 4000
lbl_award.Left = Screen.Width / 2 - lbl_award.Width / 2 + 500


img_award.Top = Screen.Height - img_award.Height
img_award.Left = Screen.Width - img_award.Width


img_logo.Top = 1
img_logo.Left = 1


img_award.Visible = False
lbl_award.Visible = False


lbl_name(0).Visible = False


Label1.Top = Screen.Height - Label1.Height
Label1.Left = 1
Label1.ForeColor = vbWhite 'RGB(119, 203, 231)


Loadlbl_name 15

img_logo.Picture = LoadPicture(App.Path & "\resource\公司logo.jpg")
strTitle = GetValue("title", "title", App.Path & "\set.ini")
lblGongsi.Caption = strTitle


End Sub


Sub Loadlbl_name(loadcount As Integer)

Dim t As Long
Dim lineno As Long

For t = 1 To loadcount
    
   
    Load lbl_name(t)
    lbl_name(t).Visible = False
    
    lineno = Int(t / 5 * (-1)) / (-1)
    
    lbl_name(t).Top = 5400 + (lineno - 1) * (lbl_name(t).Height + 400)
    
    lbl_name(t).Left = Screen.Width / 2 + 3000 * ((t Mod 5) - 1) - 6000
   
  
Next


End Sub


Private Sub Form_Load()



ReDim ArrName(0 To 0)
ReDim ArrRndNo(0 To 0)

ReadManList


InitUI

Me.Picture = LoadPicture(App.Path & "\resource\主界面.jpg")
Me.AutoRedraw = True

AwardCount = 5
StartCount = 0

End Sub


Sub ReadManList()


Dim tempStr As String '定义变量tempStr为字符串
ReDim ArrMan(0 To 2, 0 To 0)
ReDim ArrMan1(0 To 2, 0 To 0)

Open App.Path & "\抽奖名单.txt" For Input As #1 '打开文件
While Not EOF(1)  '读取到结束
  
   Line Input #1, tempStr '读取一行到变量tempStr
   
    ReDim Preserve ArrMan(0 To 2, 0 To UBound(ArrMan, 2) + 1)
    ArrMan(1, UBound(ArrMan, 2)) = UBound(ArrMan, 2)
    ArrMan(2, UBound(ArrMan, 2)) = tempStr
   
'对应的处理
Wend '未结束继续
Close #1 '关闭


Open App.Path & "\抽奖名单1.txt" For Input As #1 '打开文件
While Not EOF(1)  '读取到结束
  
   Line Input #1, tempStr '读取一行到变量tempStr
   
    ReDim Preserve ArrMan1(0 To 2, 0 To UBound(ArrMan1, 2) + 1)
    ArrMan1(1, UBound(ArrMan1, 2)) = UBound(ArrMan1, 2)
    ArrMan1(2, UBound(ArrMan1, 2)) = tempStr
   
'对应的处理
Wend '未结束继续
Close #1 '关闭

'Stop


End Sub


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 2 Then
    Me.PopupMenu menu_start

End If

End Sub

Private Sub Form_Resize()

Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight


End Sub





Private Sub menu_awardlist_Click()

FrmAward.Show

End Sub

Private Sub menu_exit_Click()

Unload Me

End Sub

Private Sub menu_luckone_Click()

Dim t As Long

If Timer1.Enabled = True Then Exit Sub

lbl_award.Caption = "幸运奖(10)"

lbl_award.Visible = True
img_award.Visible = True

AwardType = "LuckOne"
AwardCount = 10


For t = 1 To 15
    If t <= AwardCount Then
        lbl_name(t).Visible = True
    Else
         lbl_name(t).Visible = False
    End If
Next


img_award.Picture = LoadPicture(App.Path & "\奖项\幸运奖.jpg")

End Sub


Private Sub menu_lucktwo_Click()

Dim t As Long

If Timer1.Enabled = True Then Exit Sub

lbl_award.Caption = "幸运奖(15)"

lbl_award.Visible = True
img_award.Visible = True

AwardType = "LuckTwo"
AwardCount = 15

For t = 1 To 15
    If t <= AwardCount Then
        lbl_name(t).Visible = True
    Else
         lbl_name(t).Visible = False
    End If
Next




img_award.Picture = LoadPicture(App.Path & "\奖项\幸运奖.jpg")

End Sub

Private Sub menu_one_Click()

Dim t As Long

If Timer1.Enabled = True Then Exit Sub

lbl_award.Caption = "一等奖(10)"

lbl_award.Visible = True
img_award.Visible = True

AwardType = "One"
AwardCount = 10


For t = 1 To 15
    If t <= AwardCount Then
        lbl_name(t).Visible = True
    Else
         lbl_name(t).Visible = False
    End If
Next


img_award.Picture = LoadPicture(App.Path & "\奖项\一等奖.jpg")


End Sub

Private Sub menu_reset_Click()

ReadManList

ReDim ArrAwardName(0 To 2, 0 To 35)

End Sub

Private Sub Timer1_Timer()

'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Dim rndNo As String
Dim strRndName As String
Dim i As Integer
Dim j As Long

Timer1.Enabled = False

Randomize (Timer)


For i = 1 To AwardCount

100:
    rndNo = Int((UBound(ArrMan, 2)) * Rnd) + 1
    ArrRndNo(i) = rndNo
    
    '''比较随机数是否重复
    For j = 1 To i - 1
        If ArrRndNo(i) = ArrRndNo(j) Then
            GoTo 100
        End If
    Next
    
    strName = ArrMan(2, rndNo)
    ArrName(i) = strName
    
    lbl_name(i).Caption = strName
       
Next


If AwardType = "One" Then

    Randomize (Timer)
    rndNo = Int((UBound(ArrMan1, 2)) * Rnd) + 1
    strName = ArrMan1(2, rndNo)
    lbl_name(rndNo).Caption = strName
    ArrName(rndNo) = strName
End If



' QuickSort ArrRndNo, False

'Stop


Timer1.Enabled = True


End Sub


'''开始抽奖
Sub StartAward()
    
    
    If UBound(ArrMan, 2) <= 5 Then MsgBox "抽奖人数不足": Exit Sub
    
    
    ''''清空随机数组
    ReDim ArrName(0 To AwardCount)
    ReDim ArrRndNo(0 To AwardCount)
    
    
    Timer1.Enabled = True
    
  
End Sub

'''结束抽奖
Sub EndAward()
    
    
    If UBound(ArrMan, 2) <= 5 Then Exit Sub
    
    Timer1.Enabled = False
    
    QuickSort ArrRndNo, False
    For t = 0 To UBound(ArrRndNo) - 1
        ArrRowRemoveNew ArrMan, ArrRndNo(t)
    Next
    
    
    Select Case AwardType
        Case "LuckOne":
        
            For t = 1 To UBound(ArrName)
                ArrAwardName(1, t) = AwardType
                ArrAwardName(2, t) = ArrName(t)
                
                SetValue "中奖名单", "幸运奖" & t, ArrName(t), App.Path & "\中奖名单.txt"
                
            Next
            
        Case "LuckTwo":
        
            For t = 1 To UBound(ArrName)
                ArrAwardName(1, t + 10) = AwardType
                ArrAwardName(2, t + 10) = ArrName(t)
                
                  
                SetValue "中奖名单", "幸运奖" & t + 10, ArrName(t), App.Path & "\中奖名单.txt"
            Next
          
            
        Case "One":
        
            For t = 1 To UBound(ArrName)
                ArrAwardName(1, t + 25) = AwardType
                ArrAwardName(2, t + 25) = ArrName(t)
                  
                SetValue "中奖名单", "一等奖" & t, ArrName(t), App.Path & "\中奖名单.txt"
            Next
            
    End Select
    
    
    'Stop
    
End Sub

 
无标题.png

免费评分

参与人数 4吾爱币 +8 热心值 +3 收起 理由
tzw1158 + 1 + 1 我很赞同!
好先生坏印象 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
无影寒冬 + 1 + 1 谢谢@Thanks!
苏紫方璇 + 5 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| huangjie_52pj 发表于 2020-11-13 23:03
bigdoog 发表于 2020-11-13 20:07
你这个在本地电脑上面怎么安装使用呢?

这个是VB代码  安装一个VB6.0企业版就可以运行。附件里有执行程序可以直接运行的
bigdoog 发表于 2020-11-14 09:01
huangjie_52pj 发表于 2020-11-13 23:03
这个是VB代码  安装一个VB6.0企业版就可以运行。附件里有执行程序可以直接运行的

好的,感谢了。
bigdoog 发表于 2020-11-13 20:07
无影寒冬 发表于 2020-11-14 07:50
感谢楼主分享
maqiao144 发表于 2020-11-14 08:26
谢谢楼主分享收藏
好先生坏印象 发表于 2020-11-22 10:40
感谢楼主热心分享!
loveangel 发表于 2020-12-9 11:00
感谢楼主的分享,收藏备用。
lunzi1026 发表于 2020-12-23 21:33
楼主看到回复一下
 楼主| huangjie_52pj 发表于 2020-12-24 10:10
lunzi1026 发表于 2020-12-23 21:33
楼主看到回复一下

有什么事情?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 09:42

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表