myform=CREATEOBJECT('lotto') myform.show
READ EVENTS
* DEFINE CLASS lotto AS form
Height = 334 Width = 437
ShowWindow = 2
DoCreate = .T.
AutoCenter = .T.
Picture = "lotto.jpg"
Caption = "Lotto Lucky Ver1.0 by greencwi@gmail.com"
ControlBox = .F.
Closable = .F.
Icon = "lotto.ico"
KeyPreview = .T.
Name = "LOTTO"
ADD OBJECT commandbutton1 AS commandbutton WITH ; Top = 276, ;
Left = 216, ;
Height = 27, ;
Width = 48, ;
FontName = "標楷體", ;
FontSize = 10, ;
Caption = "開始", ;
Name = "commandbutton1"
ADD OBJECT label1 AS label WITH ; AutoSize = .T., ;
FontBold = .F., ;
FontName = "標楷體", ;
FontSize = 12, ;
Caption = "幸運號碼:", ;
Height = 21, ;
Left = 12, ;
Top = 276, ;
Width = 74, ;
ForeColor = RGB(255,255,255), ;
Name = "label1"
ADD OBJECT n1 AS textbox WITH ; FontBold = .T., ;
FontOutline = .F., ;
FontShadow = .T., ;
FontSize = 12, ;
Alignment = 2, ;
BorderStyle = 0, ;
Height = 23, ;
Left = 36, ;
SpecialEffect = 1, ;
Top = 12, ;
Width = 48, ;
Style = 0, ;
DisabledBackColor = RGB(255,255,255), ;
DisabledForeColor = RGB(128,0,64), ;
BorderColor = RGB(255,255,255), ;
Name = "n1"
ADD OBJECT n2 AS textbox WITH ; FontBold = .T., ;
FontOutline = .F., ;
FontShadow = .T., ;
FontSize = 12, ;
Alignment = 2, ;
BorderStyle = 0, ;
Height = 23, ;
Left = 96, ;
SpecialEffect = 1, ;
Top = 12, ;
Width = 48, ;
Style = 0, ;
DisabledBackColor = RGB(255,255,255), ;
DisabledForeColor = RGB(128,0,64), ;
BorderColor = RGB(255,255,255), ;
Name = "n2"
ADD OBJECT n3 AS textbox WITH ; FontBold = .T., ;
FontOutline = .F., ;
FontShadow = .T., ;
FontSize = 12, ;
Alignment = 2, ;
BorderStyle = 0, ;
Height = 23, ;
Left = 156, ;
SpecialEffect = 1, ;
Top = 12, ;
Width = 48, ;
Style = 0, ;
DisabledBackColor = RGB(255,255,255), ;
DisabledForeColor = RGB(128,0,64), ;
BorderColor = RGB(255,255,255), ;
Name = "n3"
ADD OBJECT n4 AS textbox WITH ; FontBold = .T., ;
FontOutline = .F., ;
FontShadow = .T., ;
FontSize = 12, ;
Alignment = 2, ;
BorderStyle = 0, ;
Height = 23, ;
Left = 216, ;
SpecialEffect = 1, ;
Top = 12, ;
Width = 48, ;
Style = 0, ;
DisabledBackColor = RGB(255,255,255), ;
DisabledForeColor = RGB(128,0,64), ;
BorderColor = RGB(255,255,255), ;
Name = "n4"
ADD OBJECT n5 AS textbox WITH ; FontBold = .T., ;
FontOutline = .F., ;
FontShadow = .T., ;
FontSize = 12, ;
Alignment = 2, ;
BorderStyle = 0, ;
Height = 23, ;
Left = 276, ;
SpecialEffect = 1, ;
Top = 12, ;
Width = 48, ;
Style = 0, ;
DisabledBackColor = RGB(255,255,255), ;
DisabledForeColor = RGB(128,0,64), ;
BorderColor = RGB(255,255,255), ;
Name = "n5"
ADD OBJECT n6 AS textbox WITH ; FontBold = .T., ;
FontOutline = .F., ;
FontShadow = .T., ;
FontSize = 12, ;
Alignment = 2, ;
BorderStyle = 0, ;
Height = 23, ;
Left = 336, ;
SpecialEffect = 1, ;
Top = 12, ;
Width = 48, ;
Style = 0, ;
DisabledBackColor = RGB(255,255,255), ;
DisabledForeColor = RGB(128,0,64), ;
BorderColor = RGB(255,255,255), ;
Name = "n6"
ADD OBJECT grid1 AS grid WITH ; ColumnCount = 6, ;
HeaderHeight = 0, ;
Height = 165, ;
Left = 36, ;
Panel = 1, ;
RecordSource = "ltmp", ;
ScrollBars = 2, ;
Top = 48, ;
Width = 367, ;
Name = "grid1", ;
Column1.ControlSource = "", ;
Column1.Width = 46, ;
Column1.Name = "Column1", ;
Column2.ControlSource = "", ;
Column2.Width = 61, ;
Column2.Name = "Column2", ;
Column3.ControlSource = "", ;
Column3.Width = 58, ;
Column3.Name = "Column3", ;
Column4.ControlSource = "", ;
Column4.Width = 59, ;
Column4.Name = "Column4", ;
Column5.ControlSource = "", ;
Column5.Width = 58, ;
Column5.Name = "Column5", ;
Column6.ControlSource = "", ;
Column6.Width = 60, ;
Column6.Name = "Column6"
ADD OBJECT lotto.grid1.column1.header1 AS header WITH ; Caption = "Header1", ;
Name = "Header1"
ADD OBJECT lotto.grid1.column1.text1 AS textbox WITH ; BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT lotto.grid1.column2.header1 AS header WITH ; Caption = "Header1", ;
Name = "Header1"
ADD OBJECT lotto.grid1.column2.text1 AS textbox WITH ; BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT lotto.grid1.column3.header1 AS header WITH ; Caption = "Header1", ;
Name = "Header1"
ADD OBJECT lotto.grid1.column3.text1 AS textbox WITH ; BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT lotto.grid1.column4.header1 AS header WITH ; Caption = "Header1", ;
Name = "Header1"
ADD OBJECT lotto.grid1.column4.text1 AS textbox WITH ; BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT lotto.grid1.column5.header1 AS header WITH ; Caption = "Header1", ;
Name = "Header1"
ADD OBJECT lotto.grid1.column5.text1 AS textbox WITH ; BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT lotto.grid1.column6.header1 AS header WITH ; Caption = "Header1", ;
Name = "Header1"
ADD OBJECT lotto.grid1.column6.text1 AS textbox WITH ; BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT label2 AS label WITH ; AutoSize = .T., ;
FontBold = .F., ;
FontName = "標楷體", ;
FontSize = 12, ;
Caption = "產生組數:", ;
Height = 21, ;
Left = 12, ;
Top = 252, ;
Width = 74, ;
ForeColor = RGB(255,255,255), ;
Name = "label2"
ADD OBJECT label3 AS label WITH ; AutoSize = .T., ;
FontBold = .F., ;
FontName = "標楷體", ;
FontSize = 12, ;
Caption = "樂透號數:", ;
Height = 21, ;
Left = 12, ;
Top = 228, ;
Width = 74, ;
ForeColor = RGB(255,255,255), ;
Name = "label3"
ADD OBJECT label4 AS label WITH ; AutoSize = .T., ;
FontName = "標楷體", ;
FontSize = 12, ;
Caption = "玩法:", ;
Height = 21, ;
Left = 204, ;
Top = 228, ;
Width = 42, ;
ForeColor = RGB(255,255,255), ;
Name = "label4"
ADD OBJECT l_type AS combobox WITH ; FontSize = 10, ;
RowSourceType = 1, ;
RowSource = "1.出現最多號碼,2.隨機", ;
Height = 24, ;
Left = 240, ;
Style = 2, ;
Top = 228, ;
Width = 156, ;
Name = "l_type"
ADD OBJECT l_num AS textbox WITH ; FontSize = 10, ;
Alignment = 1, ;
Value = 49, ;
Height = 23, ;
InputMask = "9999999999", ;
Left = 84, ;
MaxLength = 10, ;
Top = 228, ;
Width = 100, ;
Name = "l_num"
ADD OBJECT l_outnum AS textbox WITH ; FontSize = 10, ;
Alignment = 1, ;
Value = 1, ;
Height = 23, ;
InputMask = "9999999999", ;
Left = 84, ;
MaxLength = 10, ;
Top = 252, ;
Width = 100, ;
Name = "l_outnum"
ADD OBJECT l_lucky AS textbox WITH ; FontSize = 10, ;
Alignment = 1, ;
Value = 1, ;
Height = 23, ;
InputMask = "9999999999", ;
Left = 84, ;
MaxLength = 10, ;
Top = 276, ;
Width = 100, ;
Name = "l_lucky"
ADD OBJECT l_disp AS label WITH ; FontBold = .T., ;
FontSize = 14, ;
BackStyle = 0, ;
Caption = "", ;
Height = 26, ;
Left = 388, ;
Top = 11, ;
Width = 44, ;
ForeColor = RGB(255,255,128), ;
Name = "l_disp"
ADD OBJECT l_print AS commandbutton WITH ; Top = 276, ;
Left = 288, ;
Height = 27, ;
Width = 48, ;
FontName = "標楷體", ;
FontSize = 10, ;
Caption = "列印", ;
Name = "l_print"
ADD OBJECT label5 AS label WITH ; AutoSize = .T., ;
FontBold = .F., ;
FontName = "標楷體", ;
FontSize = 12, ;
Caption = "訊息", ;
Height = 21, ;
Left = 12, ;
Top = 312, ;
Width = 34, ;
ForeColor = RGB(255,255,255), ;
Name = "label5"
ADD OBJECT cmsg AS textbox WITH ; FontName = "標楷體", ;
FontSize = 10, ;
Alignment = 0, ;
Value = "祝您中大獎,中了以後分我1/3,謝謝!! 請按開始執行.....", ;
Enabled = .F., ;
Height = 23, ;
Left = 48, ;
Top = 307, ;
Width = 372, ;
DisabledBackColor = RGB(255,255,128), ;
DisabledForeColor = RGB(255,0,0), ;
Name = "cMsg"
PROCEDURE load CREATE CURSOR ltmp (n1 n(2,0),n2 n(2,0),n3 n(2,0),n4 n(2,0),n5 n(2,0),n6 n(2,0))
ENDPROC
PROCEDURE btn_defaexit.Click quit
*DODEFAULT()
ENDPROC
PROCEDURE commandbutton1.Click *
Local wl_lucky
wl_lucky=Thisform.l_lucky.Value
wl_num=Thisform.l_num.Value
wl_outnum=Thisform.l_outnum.Value
IF wl_lucky<=0 OR wl_outnum<=0
=messagebox("輸入的組數,或幸運號碼錯誤!",0,"錯誤",3000)
RETURN .F.
endif
*
Select ltmp
ZAP
SET ESCAPE ON
is_run=.T.
ON ESCAPE is_run=.F.
Do Case
Case Thisform.l_type.ListIndex=1 &&取最大數
For r=1 To wl_outnum
thisform.cmsg.Value="若要停止執行請按[ESC],目前執行..."+ALLTRIM(STR(r))+"/"+ALLTRIM(STR(wl_outnum))
DIMENSION la[wl_num]
FOR u=1 TO wl_num
la[u]=0
NEXT u
*
For j=1 To 6
nj='n'+Alltrim(Str(j))
*產生號碼
Do While .T.
IF !is_run
is_run=.t.
*=messagebox("輸入的組數,或幸運號碼錯誤!",0,"錯誤",3000)
*return
thisform.cmsg.Value="請選擇....."
ans=MESSAGEBOX("您確定要停止出號嗎?",4,"您按了ESC鍵!")
thisform.cmsg.Value=""
IF ans=6
thisform.cmsg.Value="祝您中大獎,中了以後分我1/3,謝謝!! 請按開始執行....."
RETURN
endif
endif
For i = 1 To wl_lucky
vv=Int(Rand()*wl_num)+1
la[vv]=la[vv]+1
Thisform.&nj..Value=vv
Next i
wget=0
wlmax=0
*取最大
FOR cc=1 TO wl_num
IF la[cc]>wget
wget=la[cc]
wlmax=cc
endif
NEXT cc
thisform.l_disp.Caption=ALLTRIM(STR(wlmax))
*檢查是否重覆
is_dup=.F.
For k=1 To j-1
nk='n'+Alltrim(Str(k))
If wlmax=Thisform.&nk..Value
is_dup=.T.
Endif
Next k
*
If !is_dup
*Thisform.&nj..Value=wlmax
Exit
Endif
ENDDO
*
Next j
* If wl_outnum>1
Select ltmp
Append Blank
DIMENSION sortnum[6]
FOR rr=1 TO 6
nrr='n'+Alltrim(Str(rr))
sortnum[rr]=Thisform.&nrr..Value
NEXT rr
=ASORT(sortnum)
For rr=1 To 6
nrr='n'+Alltrim(Str(rr))
Replace &nrr With sortnum[rr]
Next rr
* Endif
Next r
Select ltmp
Go Top
Thisform.Refresh()
*******************
Case Thisform.l_type.ListIndex=2 &&隨機
For r=1 To wl_outnum
thisform.cmsg.Value="若要停止執行請按[ESC],目前執行..."+ALLTRIM(STR(r))+"/"+ALLTRIM(STR(wl_outnum))
For j=1 To 6
nj='n'+Alltrim(Str(j))
Do While .T.
IF !is_run
is_run=.t.
*=messagebox("輸入的組數,或幸運號碼錯誤!",0,"錯誤",3000)
*return
thisform.cmsg.Value="請選擇....."
ans=MESSAGEBOX("您確定要停止出號嗎?",4,"您按了ESC鍵!")
thisform.cmsg.Value=""
IF ans=6
thisform.cmsg.Value="祝您中大獎,中了以後分我1/3,謝謝!! 請按開始執行....."
RETURN
endif
endif
*
For i = 1 To wl_lucky
Thisform.&nj..Value=Int(Rand()*wl_num)+1
Next i
*檢查是否重覆
is_dup=.F.
For k=1 To j-1
nk='n'+Alltrim(Str(k))
If Thisform.&nj..Value==Thisform.&nk..Value
is_dup=.T.
Endif
Next k
If !is_dup
Exit
Endif
Enddo
Next j
*If wl_outnum>1
Select ltmp
Append Blank
DIMENSION sortnum[6]
FOR rr=1 TO 6
nrr='n'+Alltrim(Str(rr))
sortnum[rr]=Thisform.&nrr..Value
NEXT rr
=ASORT(sortnum)
For rr=1 To 6
nrr='n'+Alltrim(Str(rr))
Replace &nrr With sortnum[rr]
Next rr
*Endif
Next r
Select ltmp
Go Top
Thisform.Refresh()
Endcase
ON ESCAPE
thisform.cmsg.Value="祝您中大獎,中了以後分我1/3,謝謝!! 請按開始執行....."
ENDPROC
PROCEDURE l_type.Init this.ListIndex=1
ENDPROC
PROCEDURE l_print.Click Select ltmp
Go Top
If !Eof()
Report Form Report\lotto To Printer Prompt
Endif
ENDPROC
ENDDEFINE *
*-- EndDefine: lotto
************************************************** |
沒有留言:
張貼留言