Home > Software engineering >  VB lottery system modification (modify the code, the first line in a particular key output TXT text)
VB lottery system modification (modify the code, the first line in a particular key output TXT text)

Time:09-26

First of all thank you all for the great god,
Lottery system is written in VB, prizes in C: \ program Files \ Microsoft Visual Studio \ WFJ TXT (WFJ. TXT) in the situation is now press Spaces or determined randomly from WFJ. TXT in the extraction of prizes, I want to modify the code set a specific key, according to the later, you can specify WFJ. TXT of the first line! code below
FORM1 code

 Option Explicit 
Dim gradeshu filenum, num, filenum1 exit1 As Integer
Dim nextline, abcd, abcde, abcdef As String

Private Sub loadlist1 (nextline As String)
Dim num1, I As an Integer
Num1=Int (Mid (nextline, InStr (nextline, "/") + 1, InStr (nextline, "") - InStr (nextline,"/") - 1)) - Int (Mid (nextline, InStr (nextline, ":") + 1, InStr (nextline, "/") - InStr (nextline, ":") - 1))
For I=1 To num1
List1. AddItem (Trim (Mid (nextline, InStr (nextline, ""))))
Next
End Sub

Private Sub b_Click ()
Dim str2 As String
Dim ab
Str2=""
Filenum1=FreeFile
Open "c: \ program Files \ Microsoft Visual Studio \ WFJ TXT" For Input As filenum1
The Do While Not EOF (filenum1)
The Line Input # filenum1 nextline
If the Trim (nextline) & lt;> "" Then str2=str2 +" "+ Trim (Mid (nextline, InStr (nextline," : ") + 1)) + "" + vbCr
Loop
The Close filenum1
Ab=MsgBox (str2 vbOKOnly, "winning Numbers")
End Sub

Private Sub c_Click ()
End
End Sub

Private Sub d_Click ()
Form2. Show
End Sub

Private Sub Form_Activate ()
Gradeshu=0
List1. Clear
List2. Clear
Filenum=FreeFile
Open "c: \ program Files \ Microsoft Visual Studio \ WFJ TXT" For Input As filenum
The Do While Not EOF (filenum)
The Line Input # filenum nextline
Nextline=Trim (nextline)
If nextline & lt;> "" Then
Gradeshu=gradeshu + 1
Loadlist1 (nextline)
List2. AddItem (Trim (Mid (nextline, InStr (nextline, ""))))
End the If
Loop
The Close filenum
If List1. ListCount & lt; 49 Then
If exit1=1 Then End
MsgBox (" winning number less than 50, draw over, increase quota can continue!
")Form2. Show
Exit1=exit1 + 1
End the If
Start. Enabled=False
End Sub

Private Sub Form_Load ()
Exit1=0
End Sub

Private Sub ABC ()
Start. Enabled=True: start. SetFocus: Call start_Click
End Sub

Private Sub Form_MouseDown (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If the Button=2 Then Form1. PopupMenu a
If the Button=1 Then Call ABC
End Sub

Private Sub Label2_Click ()
Call ABC
End Sub

Private Sub Label4_Click ()
Call ABC
End Sub

Private Sub Label5_Click ()
Call ABC
End Sub

Private Sub pause_Click ()
Dim As Integer I
Dim str1 (0 To 30) As String
Dim a, str2, num1 As String
Pause. Enabled=False
Timer1. Enabled=False
Randomize
I=Int (List1. ListCount * Rnd (1))
A=Trim (List1. List (I))


Label4. Caption=vbCr + a
List1. RemoveItem (I)
I=0
Filenum=FreeFile
Open "c: \ program Files \ Microsoft Visual Studio \ WFJ TXT" For Input As filenum
The Do While Not EOF (filenum)
The Line Input # filenum nextline
If the Trim (nextline) & lt;> "" Then str1 (I)=Trim (nextline) : I=I + 1
Loop
The Close filenum
Filenum=FreeFile
Open "c: \ program Files \ Microsoft Visual Studio \ WFJ TXT" For the Output As filenum
For I=0 To gradeshu - 1
If a=Trim (Mid (str1 (I), InStr (str1 (I), ""))) Then
Label5. Caption=Mid (str1 (I), 1, 3)
Num1=Int (Mid (str1 (I), InStr (str1 (I), ":") + 1, InStr (str1 (I), "/") - InStr (str1 (I), ":") - 1)) + 1
Str1 (I)=Mid (str1 (I), 1, InStr (str1 (I), ":")) + num1 + Mid (str1 (I), InStr (str1 (I), "/"))
End the If
Print # filenum, str1 (I)
Next
The Close filenum
Num=0
End Sub

Private Sub start_Click ()
If List1. ListCount=99 Then MsgBox (" winning number less than 100, notify the marketing planning department increase the quota of people!
")If List1. ListCount=79 Then MsgBox (" winning number less than 80, notify the marketing planning department increase the quota of people!
")If List1. 49 Then ListCount=MsgBox (" winning number less than 50, draw the end, increase the quota can continue! ") : the Exit Sub
Start. Enabled=False
Pause. Enabled=True
Pause. SetFocus
Timer1. Enabled=True
End Sub

Private Sub Timer1_Timer ()
Randomize
Label4. Caption=vbCr + List2. List (Int (gradeshu * Rnd (2)))
End Sub



FORM2 code

 Option Explicit 
Dim filenum As Integer
Dim nextline As String

Private Sub Command1_Click ()
Dim STR As String
If the Trim (Text1. Text)="24680" Then
STR=Trim (RichTextBox1. Text) + vbCrLf
Filenum=FreeFile
Open "c: \ program Files \ Microsoft Visual Studio \ WFJ TXT" For the Output As filenum
The Do While Len (STR) & gt; 8
Print # filenum, Mid (STR, 1, InStr (STR, vbCrLf) - 1)
STR=Mid (STR, InStr (STR, vbCrLf) + 2)
Loop
Close # filenum
Set up successfully saved MsgBox (" award!
")Text1. Text=""
Command2. SetFocus
The Else
MsgBox "the password is not correct! ",, "tip" : Text1. Text="" : Text1. SetFocus
End the If
End Sub

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related