메뉴 건너뛰기

app

[evb] 로또번호생성기 using Function Rnd

박영식2006.08.29 16:05조회 수 4650댓글 0

  • 1
    • 글자 크기
Rnd 라는 함수를 이용해서

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

위와 같은 형태로 정수화된 숫자를 얻을 수 있다. 아직 버그가 있다면, 보너스 번호와 다른 숫자가 겹칠 수 있다는 것이다. 그리고 이것은 순전히 한 번호대당 한개 이상의 숫자가 나온다는 가정에 의한 것이므로, 당첨확률은 아마 더 낮아질 것이다. 번호생성방식이 아예 다르기 때문이다. 여러가지 버그 등은 곧 수정할 것이다.

<rndfunc.ebp>
Type=Exe
PlatformGUID={DE9660AC-85D3-4C63-A6AF-46A3B3B83737}
DeviceGUID={5F2AD043-32BE-4874-B5B1-B16758EC1B1D}
RemotePath=WindowsStart MenuProject1.vb
UpdateType=1
ForceRuntime=0
ForceComponent=0
Reference=*G{00020430-0000-0000-C000-000000000046}#2.0#0#C:WINDOWSsystem32stdole2.tlb#OLE Automation
Form=rndfunc.ebf
IconForm="Form1"
Startup="Form1"
ExeName32="rndfunc.vb"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="Microsoft Corporation"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1

[OtherInfo]
ProjectType=WinCE
Platform={DE9660AC-85D3-4C63-A6AF-46A3B3B83737}


<rndfunc.ebf>
VERSION 5.00
Begin VB.Form Form1
   Appearance      =   0  'Flat
   BackColor       =   &H0080C0FF&
   Caption         =   "Form1"
   ClientHeight    =   3540
   ClientLeft      =   60
   ClientTop       =   840
   ClientWidth     =   3480
   ForeColor       =   &H80000008&
   ScaleHeight     =   3540
   ScaleWidth      =   3480
   ShowOK          =   -1  'True
   Begin VBCE.Label bon
      Height          =   200
      Left            =   2000
      TabIndex        =   8
      Top             =   2500
      Width           =   230
      _cx             =   406
      _cy             =   353
      AutoSize        =   0   'False
      BackColor       =   8454143
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   ""
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.Label fot
      Height          =   200
      Left            =   2000
      TabIndex        =   7
      Top             =   2200
      Width           =   230
      _cx             =   406
      _cy             =   353
      AutoSize        =   0   'False
      BackColor       =   8454143
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   ""
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.Label tht
      Height          =   200
      Left            =   2000
      TabIndex        =   6
      Top             =   1900
      Width           =   230
      _cx             =   406
      _cy             =   353
      AutoSize        =   0   'False
      BackColor       =   8454143
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   ""
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.Label twt
      Height          =   200
      Left            =   2000
      TabIndex        =   5
      Top             =   1600
      Width           =   230
      _cx             =   406
      _cy             =   353
      AutoSize        =   0   'False
      BackColor       =   8454143
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   ""
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.Label ten
      Height          =   200
      Left            =   2000
      TabIndex        =   4
      Top             =   1300
      Width           =   230
      _cx             =   406
      _cy             =   353
      AutoSize        =   0   'False
      BackColor       =   8454143
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   ""
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.Label one
      Height          =   200
      Left            =   2000
      TabIndex        =   3
      Top             =   1000
      Width           =   230
      _cx             =   406
      _cy             =   353
      AutoSize        =   0   'False
      BackColor       =   8454143
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   ""
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.Label Label2
      Height          =   1800
      Left            =   500
      TabIndex        =   2
      Top             =   1000
      Width           =   500
      _cx             =   873
      _cy             =   3175
      AutoSize        =   0   'False
      BackColor       =   8454016
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   "1 10 20 30 40 α"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "HY견고딕"
         Size            =   14.25
         Charset         =   129
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.CommandButton Command1
      Height          =   495
      Left            =   1800
      TabIndex        =   1
      Top             =   3000
      Width           =   1575
      _cx             =   2778
      _cy             =   873
      BackColor       =   12632256
      Caption         =   "생성하기"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "HY센스L"
         Size            =   12
         Charset         =   129
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Style           =   0
   End
   Begin VBCE.Label Label1
      Height          =   315
      Left            =   480
      TabIndex        =   0
      Top             =   360
      Width           =   2580
      _cx             =   4551
      _cy             =   556
      AutoSize        =   -1  'True
      BackColor       =   8438015
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   "로또 번호 생성기"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "HY엽서M"
         Size            =   15.75
         Charset         =   129
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   2
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
    Dim num1 As Integer
    num1 = Int((9 - 1 + 1) * Rnd + 1)
    one.Caption = num1
    ' 최상값이 9
    num1 = Int((19 - 10 + 1) * Rnd + 10)
    ten.Caption = num1
    ' 최상값이 19
    num1 = Int((29 - 20 + 1) * Rnd + 20)
    twt.Caption = num1
    ' 최상값이 29
    num1 = Int((39 - 30 + 1) * Rnd + 30)
    tht.Caption = num1
    ' 최상값이 39
    num1 = Int((45 - 40 + 1) * Rnd + 40)
    fot.Caption = num1
    ' 최상값이 45
    num1 = Int((45 - 1 + 1) * Rnd + 1)
    bon.Caption = num1
    ' 보너스 넘버
End Sub

Private Sub Form_OKClick()
    App.End
End Sub

Private Sub one_Click()

End Sub

박영식 (비회원)
  • 1
    • 글자 크기
[evb] CD 관리기 using ADOCE 3.0 (by 박영식) [evb] 안녕하세요. 포켓 PC 2002 프로그래밍 (by 박영식)

댓글 달기

박영식
2007.07.08 조회 2358
박영식
2007.06.14 조회 2633
박영식
2007.04.04 조회 5643
박영식
2007.02.16 조회 2443
박영식
2007.02.15 조회 2638
박영식
2006.09.19 조회 1927
박영식
2006.09.14 조회 1973
박영식
2006.09.09 조회 1903
박영식
2006.09.05 조회 1963
박영식
2006.09.01 조회 1575
첨부 (1)
rndfunc.JPG
16.8KB / Download 48
위로