当前位置:编程学习 > VB >>

请问VB乐透程序

如何用VB设计乐透开奖系统按 开奖 钮后会显示六个1-42不重复乱数号码再按 排序 钮后 六个号码由小至大排列。
答案:
Public Class Form1 Dim num(6) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim I, J As Integer Dim s As String Randomize() For I = 1 To 6again: num(I) = Int((Rnd() * 42) + 1) If I >= 2 Then For J = 1 To I - 1 If num(I) = num(J - 1) Then GoTo again Next J End If s = s + Str(num(I)) & " , " Next I MsgBox("开奖: " & s) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim ss As String Array.Sort(num) For i As Integer = 1 To 6 ss = ss + Str(num(i)) & "," Next MsgBox("排序: " & ss) End SubEnd Class
到问吧askx.org网站查看回答详情>>

上一个:VB连接access数据库
下一个:讲解VB画圆

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,