Home > Software engineering >  VB foundation, random number
VB foundation, random number

Time:11-22

Randomly generated 10 can be divided exactly by 3 and you can't be divided exactly by 5 three integers

CodePudding user response:

 
Option Explicit

Private Sub Command1_Click ()
Dim aryResult (9) As Long
Dim aryCount As Long
Dim lngTmp As Long
Dim blnExists As Boolean
Dim As Integer I
Do
LngTmp=100 + Rnd (Now ()) * 900 'random three digits
If lngTmp/3 & lt;> LngTmp \ 3 And lngTmp/5 & lt;> 5 Then lngTmp \ 'neither for the divided exactly by 3 or divided exactly by 5
BlnExists=False
For I=LBound (aryResult) To UBound (aryResult) 'the answer To determine whether there have been a
If aryResult (I)=lngTmp Then
BlnExists=True
End the If
Next
If Not blnExists Then 'If Not repeat results Then document the results
AryResult (aryCount)=lngTmp
AryCount=aryCount + 1
End the If
End the If
Loop While aryCount & lt; When the result is 10 out of 10 '

For I=LBound (aryResult) To UBound (aryResult) 'output
The Debug. Print aryResult (I)
Next
End Sub

CodePudding user response:

Bosses, I according to this I can't, couldn't have been lost

CodePudding user response:

The code is as follows:
 
Option Explicit

Private Sub Form_Load ()
Dim colNumbers As New Collection

Dim As Integer I
For I=100 To 999
If I Mod 3=0 And I Mod 5 & lt;> 0 Then
ColNumbers. Add the I
End the If
Next

For I=1 To 10
Randomize

Dim j As Integer
J=Int (Rnd * colNumbers. Count) + 1

The Debug. Print colNumbers (j)
ColNumbers. Remove j
Next
End Sub

Run the example:

Download address:
Link: https://pan.baidu.com/s/1lkvgL7tx0xu3gAMg5bhcAA
The extracted code: hvid

CodePudding user response:

VB6.0 by use is too backward? Or I can't

CodePudding user response:

Immediate window without the data?

CodePudding user response:

Where did you lose the code? Is the main form of input?

CodePudding user response:

reference 4 floor qq_44815320 response:
VB6.0 by use are too behind The Times? Or I can't

"Behind" is not a programming language, but the level of the people...

CodePudding user response:

refer to 6th floor milaoshu1020 response:
code: where did you lose? Is the main form of input?

Yes, lose the past is nothing??

CodePudding user response:

My level is low, but according to the code, or I can't, I mean the code is not in VB6.0 by use

CodePudding user response:

If you don't, you can download the code and run the VB project.
I send first reply have download address, you check out.

CodePudding user response:

references 9 f qq_44815320 response:
my level is low, but according to the code, or I can't, I mean the code is not in VB6.0 by use

They give you code, and the output in the "window" immediately,
Do you want to open the window, immediately to see the output data,
(don't know whether you understand what is the "window" immediately VB6... )

If you don't know, ask your teacher or a classmate,
Also, run the VB6, create a new standard EXE engineering ", draw a button in the window,
In the form in the code window paste the code on the 1st floor,
Then put the 26 Debug. Print to me. Print
To run the program, click the button, you see the results,

CodePudding user response:

Yes, please, thank you!

CodePudding user response:

According to the 'CTRL + G' can bring up the window immediately.

CodePudding user response:

reference 13 floor milaoshu1020 reply:
'CTRL + G' can bring up the window immediately.

Well well, thank you, I know
  • Related