#### Topic: How to initialize a two-dimensional array random numbers?

Actually a question in a subject, but just in case I will repeat: How to initialize a two-dimensional array random numbers in VB6?
I will be grateful, if explain

#### Re: How to initialize a two-dimensional array random numbers?

Actually I write the program on a problem: the two-dimensional array by dimensionality N x M elements Is given.
To define an amount of the elements, which values more than the given number F.
Also I can not randomize number in an array.

Dim am () As Integer
Private Sub Command1_Click ()
N = Val (Text1)
M = Val (Text2)
F = Val (Text3)
k = 0
am (i, j) =? Here also it is impossible
For i = 0 To N - 1
For j = 0 To M - 1
If am (i, j)&gt; F Then k = k + 1
Next
Next
Picture1.Print am (i, j);
Picture2.Print k
End Sub

#### Re: How to initialize a two-dimensional array random numbers?

fess56rus wrote:

How to initialize a two-dimensional array random numbers in VB6?

the Nested loop on two measurements of an array (the full bypass of an array) and assignment to each element of a random number. Five code lines. What was specific it is impossible?

#### Re: How to initialize a two-dimensional array random numbers?

To initialize in the same way as then you search - in a double cycle, on one element.

#### Re: How to initialize a two-dimensional array random numbers?

Shocker. Pro;
So, I at all do not understand a BASIC. Two-dimensional arrays - not mine. It is impossible to me to create  an array = (

#### Re: How to initialize a two-dimensional array random numbers?

Dim am () As Integer ' the array is declared, but not initialized
Private Sub Command1_Click ()
N = Val (Text1)
M = Val (Text2)
F = Val (Text3)
k = 0
ReDim am (N, M) ' array initialization
Randomize Timer ' initialization of the generator of random numbers by the timer - for  randomnesses
' filling of an array with random numbers
For i = 0 To N - 1
For j = 0 To M - 1
am (i, j) = Rnd (Timer) * F * 2 ' Rnd returns decimal value from zero to unit.
' as value range F is coded, we multiply it by two that in an array were both the big and smaller values.
' the timer - for even  randomnesses
Next
Next
For i = 0 To N - 1
For j = 0 To M - 1
If am (i, j)&gt; F Then k = k + 1
Next
Next
Picture1.Print am (i, j);
Picture2.Print k
End Sub

#### Re: How to initialize a two-dimensional array random numbers?

fess56rus;
Well esteem though a little.
It is necessary for you:
To initialize the generator of random numbers;
In a cycle to fill your two-dimensional array.

' Initialize the random-number generator.
Randomize ()
' Generate random value between 1 and 6.
Dim value As Integer = CInt (Int ((6 * Rnd ()) + 1))

#### Re: How to initialize a two-dimensional array random numbers?

by-pass wrote:

fess56rus;
Well esteem though a little.
It is necessary for you:
To initialize the generator of random numbers;
In a cycle to fill your two-dimensional array.

' Initialize the random-number generator.
Randomize ()
' Generate random value between 1 and 6.
Dim value As Integer = CInt (Int ((6 * Rnd ()) + 1))

.

#### Re: How to initialize a two-dimensional array random numbers?

fess56rus wrote:

Shocker. Pro;
So, I at all do not understand a BASIC. Two-dimensional arrays - not mine. It is impossible to me to create  an array = (

If you do not understand Basic and such elementary bases, means to learn you it and to try it it does not make sense to hand over. It is necessary to return to bases and to learn all at first.
Basic the elementary programming language, but to given (your) question it practically has no what relation.
In any language initialization 2 an array is carried out by random numbers equally. Or undertake a head,  books and learn to read, or think of other trade where it will not be necessary to learn Basic, elementary of high level languages

#### Re: How to initialize a two-dimensional array random numbers?

If it is necessary simply the answer it is not necessary to create an array even.
The random number is generated and it is considered how many more than set and all :-)

#### Re: How to initialize a two-dimensional array random numbers?

Roman Mejtes;
to me it is necessary only for the tolerance to offsets at the first year, further it is not required to me in any time

Antonariy;
Thanks

#### Re: How to initialize a two-dimensional array random numbers?

The task is solved, all thanks

Dim am () As Integer
Private Sub Command1_Click ()
Picture1.Cls
Picture2.Cls
n = Val (Text1)
m = Val (Text2)
F = Val (Text3)
k = 0
Dim s As String
Dim am () As Long
Dim mas () As Long
ReDim am (n, m)
Randomize Timer
For i = 0 To n - 1
For j = 0 To m - 1
am (i, j) = Rnd (Timer) * F * 2
If am (i, j)&gt; F Then k = k + 1
s = s AND am (i, j) AND ""
Next
s = s AND vbCrLf
Next
Picture1.Print s
Picture2.Print k
End Sub