VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4092
ClientLeft = 48
ClientTop = 324
ClientWidth = 2520
LinkTopic = "Form1"
ScaleHeight = 4092
ScaleWidth = 2520
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Generate
Caption = "Generate"
Height = 372
Left = 240
TabIndex = 1
Top = 3480
Width = 1932
End
Begin VB.ListBox List1
Height = 2928
Left = 240
TabIndex = 0
Top = 240
Width = 1932
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 Form_Load()
Randomize
End Sub
Private Sub Generate_Click()
Dim i, j As Integer
Dim nums(20) As Integer
Dim found As Boolean
Dim tmp As Integer
List1.Clear
i = 0
While (i < 20)
again:
tmp = Int((30000 * Rnd) + 1)
found = False
For j = 0 To i - 1
If nums(j) = tmp Then
found = True
Exit For
End If
Next j
If found Then GoTo again
nums(i) = tmp
List1.AddItem (tmp)
i = i + 1
Wend
End Sub
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4092
ClientLeft = 48
ClientTop = 324
ClientWidth = 2520
LinkTopic = "Form1"
ScaleHeight = 4092
ScaleWidth = 2520
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Generate
Caption = "Generate"
Height = 372
Left = 240
TabIndex = 1
Top = 3480
Width = 1932
End
Begin VB.ListBox List1
Height = 2928
Left = 240
TabIndex = 0
Top = 240
Width = 1932
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 Form_Load()
Randomize
End Sub
Private Sub Generate_Click()
Dim i, j As Integer
Dim nums(20) As Integer
Dim found As Boolean
Dim tmp As Integer
List1.Clear
i = 0
While (i < 20)
again:
tmp = Int((30000 * Rnd) + 1)
found = False
For j = 0 To i - 1
If nums(j) = tmp Then
found = True
Exit For
End If
Next j
If found Then GoTo again
nums(i) = tmp
List1.AddItem (tmp)
i = i + 1
Wend
End Sub
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
For i = 1 To N
generate:
numbers(i) = Int(N * Rnd()) + 1
For j = 1 To i -1
If numbers(i) = numbers(j) Then
goto generate
End If
Next j
ListBox1.Items.Add(numbers(i))
Next i
repeated = False
If i > 1 Then
For j = 1 To i - 1
If numbers(i) = numbers(j) Then
repeated = True
End If
Next
End If
again:
tmp = Int((30000 * Rnd) + 1)
found = False
For j = 0 To i - 1
If nums(j) = tmp Then
found = True
Exit For
End If
Next j
If found Then GoTo again
nums(i) = tmp
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.