Requirements are as follows:
Press the start button in the interface of random fast scroll 1. TXT in the name,
Press the stop button to stop rolling, the interface is shown in one of the name, and to be written to the 2. TXT,
2. TXT in the name no longer shows that after the lottery unless you press the reset button,
CodePudding user response:
The ill effects of an array or a collection, as in the listingThrow the name,
Random scroll, is randomly generated within the scope of an array or collection subscript subscript, then extract the subscript showed that the content of the
Determine the lottery, is randomly generated an array or collection subscript subscript, within the scope of the element extracted on the winning list or variable, and delete the previous array or collection,
Suggested above, actually written word is more than the implementation of the code, but of homework to do,
CodePudding user response:
Private Sub Start ()
A="D: \ TEST \ TEMP. CSV"
Open a For Input As # 1
Arr=Split (StrConv (InputB (LOF (1), 1), vbUnicode), vbCrLf)
Close # 1
Open a For the Output As # 2
B=UBound (arr) - 1
Randomize
D=arr (Int * Rnd (b) + 1)
Label1. Caption=d
For I=0 To UBound (arr)
If Len (arr (I)) & lt;> 0 Then
Print # 2, arr (I)
End the If
Next
Close # 2
End Sub
Private Sub Command1_Click ()
Timer1_Timer
End Sub
Private Sub Command2_Click ()
Stop_1
End Sub
Private Sub Command3_Click ()
Timer1. Enabled=False
If Dir (" D: \ TEST \ ", vbDirectory)="" Then MkDir (" D: \ TEST ")
A="D: \ TEST \ 2. CSV"
Open a For the Output As the # 1
Print # 1, "directory"
Close # 1
A="D: \ TEST \ 1. CSV"
Open a For Input As # 1
Arr=Split (StrConv (InputB (LOF (1), 1), vbUnicode), vbCrLf)
Close # 1
A="D: \ TEST \ TEMP. CSV"
Open a For the Output As # 2
For I=0 To UBound (arr) - 1
Print # 2, arr (I)
Next
Close # 2
End Sub
Private Sub Form_Load ()
If Dir (" D: \ TEST \ ", vbDirectory)="" Then MkDir (" D: \ TEST ")
A="D: \ TEST \ 2. CSV"
Open a For the Output As the # 1
Print # 1, "directory"
Close # 1
A="D: \ TEST \ 1. CSV"
Open a For Input As # 1
Arr=Split (StrConv (InputB (LOF (1), 1), vbUnicode), vbCrLf)
Close # 1
A="D: \ TEST \ TEMP. CSV"
Open a For the Output As # 2
For I=0 To UBound (arr) - 1
Print # 2, arr (I)
Next
Close # 2
End Sub
Private Sub stop_1 ()
Timer1. Enabled=False
A="D: \ TEST \ 2. CSV"
Aa="D: \ TEST \ TEMP. CSV"
The Open aa For Input As # 1
Arr=Split (StrConv (InputB (LOF (1), 1), vbUnicode), vbCrLf)
Close # 1
Open a For Input As # 11
BRR=Split (StrConv (InputB (LOF (11), 11), vbUnicode), vbCrLf)
Close # 11
Open a For the Output As # 2
The Open aa For the Output As # 22
A For b=0 To UBound (arr)
If Len (arr) (b) & lt;> 0 Then
If arr (b) & lt;> Label1. Caption Then
Print # 22, arr (b)
End the If
End the If
Next
A For b=0 To UBound (BRR) - 1
Print # 2, BRR (b)
Next
Print # 2, Label1 Caption
Close # 2
Close # 22
End Sub
Private Sub Timer1_Timer ()
Timer1. Enabled=True
Timer1. Interval=200
Call Start
End Sub
You can have a try, my original file use. CSV format, the. TXT file will be garbled other basic can meet your request, the content of some white elephants in some places you can try to change me is also a beginner, we learn from each other
CodePudding user response:
https://jingyan.baidu.com/article/dca1fa6f720b72f1a440520f.htmlCodePudding user response:
Can try excel,The first column name, the second column filled with formula=RAND (), open the filter for the second column sorting can, want a few will take a few lines,
CodePudding user response:
I also wrote a, the code is as follows:
Option Explicit
Private fso As New FileSystemObject
Private McOlNames As New Collection
Private mintIndex As Integer
Private Property Get File1Path () As String
File1Path=fso. BuildPath (App) Path, "1. TXT")
End Property
Private Property Get File2Path () As String
File2Path=fso. BuildPath (App) Path, "2. TXT")
End Property
Private Sub cmdReset_Click ()
Dim objStream As TextStream
The Set objStream=fso. OpenTextFile (File2Path ForWriting, True)
ObjStream. Close
End Sub
Private Sub cmdStart_Click ()
Dim As Long I
For I=1 To McOlNames. Count
McOlNames. Remove 1
Next
Dim objStream As TextStream
The Set objStream=fso. OpenTextFile (File1Path ForReading, False)
While Not objStream. AtEndOfStream
Dim strName As String
StrName=objStream. ReadLine ()
McOlNames. Add strName
Wend
ObjStream. Close
The Set objStream=fso. OpenTextFile (File2Path ForReading, False)
While Not objStream. AtEndOfStream
StrName=objStream. ReadLine ()
For I=McOlNames. Count To 1 Step 1
If McOlNames (I)=strName Then
McOlNames. Remove the I
The Exit For
End the If
Next
Wend
ObjStream. Close
If McOlNames. Count & gt; 0 Then
Timer1. Enabled=True
The Else
MsgBox "already all draw!" , vbExclamation
End the If
End Sub
Private Sub cmdStop_Click ()
Timer1. Enabled=False
Dim objStream As TextStream
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull