vb编写彩票选号器的问题,请高手进来

vb编写彩票选号器的问题,请高手进来,第1张

Private Sub Command1_Click()

Dim i, a(34), b(7)

Randomize: Cls

For i = 1 To 7

b(i) = Int(Rnd * 34 + 1)

If a(b(i)) Then i = i - 1 Else a(b(i)) = 1

Next

Print "34 选 7组 福利彩票系统,中奖号码:"

For i = 1 To 7

Print b(i)

Next

End Sub

请不要发违规广告,是违法行为

 

Private Sub Command1_Click()

If IsNumeric(Text1) And Len(Text1) = 7 Then '判断输入的是否为7位数字

Randomize

a = Format(Int(Rnd * 9999999 + 1), "0000000") '生成开奖号码

Label1.Caption = "本期开奖号码为:" & a

For i = 1 To 7 '逐位判断是否相同,b为相同个数

If Mid(Text1, i, 1) = Mid(a, i, 1) Then

b = b + 1

End If

Next

If b = 7 Then

Label2.Caption = "恭喜你中得一等奖"

ElseIf b = 6 Then

Label2.Caption = "恭喜你中得二等奖"

ElseIf b = 5 Then

Label2.Caption = "恭喜你中得三等奖"

'以此类推判断是否中奖

Else

Label2.Caption = "很遗憾,差一点就中奖了"

End If

Else

MsgBox "请输入一个七位数字"

Exit Sub

End If

End Sub

把下面的代码复制到记事本中,改名为form1.frm,再用vb6打开编译即可使用。希望你能喜欢,不足之处可以提出来。

VERSION 5.00

Begin VB.Form Form1

BorderStyle = 5 'Sizable ToolWindow

Caption = "彩票选号程序"

ClientHeight= 3855

ClientLeft = 60

ClientTop = 330

ClientWidth = 6600

LinkTopic = "Form1"

MaxButton = 0 'False

MinButton = 0 'False

ScaleHeight = 3855

ScaleWidth = 6600

ShowInTaskbar = 0 'False

StartUpPosition = 3 '窗口缺省

Begin VB.Frame Frame4

Caption = "号码框"

Height = 2415

Left= 3600

TabIndex= 11

Top = 1320

Width = 2895

Begin VB.CommandButton Command6

Caption = "输入号码"

Height = 255

Left= 1560

TabIndex= 19

Top = 720

Width = 1095

End

Begin VB.CommandButton Command5

Caption = "试试运气"

Height = 495

Left= 120

TabIndex= 16

Top = 1440

Width = 2535

End

Begin VB.TextBox xx

Height = 270

Left= 1560

TabIndex= 14

Top = 1080

Width = 1095

End

Begin VB.TextBox sx

Height = 270

Left= 120

TabIndex= 13

Top = 1080

Width = 1095

End

Begin VB.Label Label5

Caption = "范围:"

Height = 255

Left= 120

TabIndex= 18

Top = 720

Width = 615

End

Begin VB.Label Label4

Caption = "机选号码:"

Height = 255

Left= 120

TabIndex= 17

Top = 2040

Width = 2535

End

Begin VB.Label Label3

Caption = "~"

BeginProperty Font

Name= "宋体"

Size= 14.25

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 135

Left= 1320

TabIndex= 15

Top = 1200

Width = 255

End

Begin VB.Label Label2

Caption = "我的号码:"

Height = 255

Left= 120

TabIndex= 12

Top = 360

Width = 2655

End

End

Begin VB.Frame Frame3

Caption = "统计框"

Height = 975

Left= 3600

TabIndex= 8

Top = 240

Width = 2895

Begin VB.CommandButton Command3

Caption = "点我统计!"

Height = 615

Left= 120

TabIndex= 9

Top = 240

Width = 2655

End

End

Begin VB.Frame Frame2

Caption = "查找框"

Height = 2415

Left= 120

TabIndex= 3

Top = 1320

Width = 3375

Begin VB.CommandButton Command4

Caption = "清除"

Height = 255

Left= 2400

TabIndex= 10

Top = 2040

Width = 855

End

Begin VB.CommandButton Command2

Caption = "查找"

Height = 255

Left= 2520

TabIndex= 7

Top = 240

Width = 735

End

Begin VB.ListBox List1

Height = 1320

ItemData= "Form1.frx":0000

Left= 120

List= "Form1.frx":0002

TabIndex= 5

Top = 600

Width = 3135

End

Begin VB.TextBox Text1

Height = 270

Left= 120

TabIndex= 4

Top = 240

Width = 2295

End

Begin VB.Label Label1

Caption = "总共:0项"

Height = 255

Left= 120

TabIndex= 6

Top = 2040

Width = 2175

End

End

Begin VB.Frame Frame1

Caption = "输入框"

Height = 1095

Left= 120

TabIndex= 0

Top = 120

Width = 3375

Begin VB.TextBox Text2

Height = 270

Left= 120

TabIndex= 2

Top = 240

Width = 3135

End

Begin VB.CommandButton Command1

Caption = "输入并确定"

Height = 375

Left= 120

TabIndex= 1

Top = 600

Width = 3135

End

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Dim N As Long

Dim NR As String

Dim ZS As Long

Dim CS As Long

Dim mynum As Long

Private Sub Command1_Click()

Open "C:\1.TXT" For Append As #1

Print #1, Val(Text2.Text)

Close #1

Label2.Caption = "我的号码:" &Val(Text2.Text)

mynum = Val(Text2.Text)

Text2.Text = ""

End Sub

Private Sub Command2_Click()

CS = CS + 1

Open "C:\1.TXT" For Input As #1

Do While Not EOF(1)

Line Input #1, NR

NR = Trim(NR)

If NR = Text1.Text Then List1.AddItem NR: N = N + 1

Loop

Close #1

List1.AddItem "------------第" &CS &"次------------"

Label1.Caption = "总共:" &N &"项"

N = 0

NR = ""

End Sub

Private Sub Command3_Click()

Open "C:\1.TXT" For Input As #1

Do While Not EOF(1)

Line Input #1, NR

NR = Trim(NR)

If NR = NR Then ZS = ZS + 1

Loop

Close #1

MsgBox "共有" &ZS &"项"

ZS = 0

End Sub

Private Sub Command4_Click()

List1.Clear

End Sub

Private Sub Command5_Click()

Label4.Caption = "机选号码:" &Int(Rnd * Val(sx.Text)) + Val(xx.Text)

End Sub

Private Sub Command6_Click()

mynum = InputBox("输入号码:")

Label2.Caption = "我的号码:" &mynum

End Sub

Private Sub Form_Load()

N = 0

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11084785.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存