how do i get 2 different number in same row? using random
example:
4 2
5 6
7 4
1 7
9 8
3 3 <===== i want different number but not same as opposite
8 5
6 8
2 1
in my code:
Dim Nine_numbers(9) as short
Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short
Dim j, k As Integer
For innn = 1 To 9
nine(innn) = innn
Next
For innn = 1 To 9
Do
Dim rng As New Random
k = rng.Next(1, 10)
Loop Until nine(k) > 0
nine(k) = 0
szArray(innn) = k
TextBox82.Text = szArray(1)
TextBox91.Text = szArray(2)
TextBox100.Text = szArray(3)
TextBox83.Text = szArray(4)
TextBox92.Text = szArray(5)
TextBox101.Text = szArray(6)
TextBox84.Text = szArray(7)
TextBox93.Text = szArray(8)
TextBox102.Text = szArray(9)
Debug.WriteLine (szArray(innn))
Next
For mmm = 1 To 9
nineA(mmm) = mmm
Next
For mmm = 1 To 9
Do
Dim rng As New Random
j = rng.Next(1, 10)
Loop Until nineA(j) > 0
nineA(j) = 0
szArray(mmm) = j
TextBox85.Text = szArray(1)
TextBox94.Text = szArray(2)
TextBox103.Text = szArray(3)
TextBox86.Text = szArray(4)
TextBox95.Text = szArray(5)
TextBox104.Text = szArray(6)
TextBox87.Text = szArray(7)
TextBox96.Text = szArray(8)
TextBox105.Text = szArray(9)
Debug.WriteLine (szArray(mmm))
Next
ne iideas?
regards 13 1500
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this
code, the makeGrid part is just to show the use of a textbox array
hth
Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
makeGrid()
fillRandom()
End Sub
Private Sub makeGrid()
Dim x As TextBox
Dim xPos, yPos As Integer
yPos = 20
For row As Integer = 0 To 8
xPos = 20
For column As Integer = 0 To 1
x = New TextBox
x.Name = (CStr(row) & CStr(column))
x.Location = New Point(xPos, yPos)
x.BorderStyle = BorderStyle.Fix edSingle
x.Width = 20
x.Height = 20
x.Text = ""
Me.Controls.Add (x)
textboxGrid(row , column) = x
xPos += 21
Next
yPos += 21
Next
End Sub
Private Sub fillRandom()
Dim blnOk As Boolean
For row As Integer = 0 To 8
blnOk = False
Do While blnOk = False
textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1)
textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1)
If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then
blnOk = True
End If
Loop
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles _ Button1.Click
fillRandom()
End Sub
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht
news:AY******** ************@ro gers.com... how do i get 2 different number in same row? using random example:
4 2 5 6 7 4 1 7 9 8 3 3 <===== i want different number but not same as opposite 8 5 6 8 2 1
in my code:
Dim Nine_numbers(9) as short Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short Dim j, k As Integer For innn = 1 To 9 nine(innn) = innn Next For innn = 1 To 9 Do Dim rng As New Random k = rng.Next(1, 10) Loop Until nine(k) > 0 nine(k) = 0 szArray(innn) = k TextBox82.Text = szArray(1) TextBox91.Text = szArray(2) TextBox100.Text = szArray(3) TextBox83.Text = szArray(4) TextBox92.Text = szArray(5) TextBox101.Text = szArray(6) TextBox84.Text = szArray(7) TextBox93.Text = szArray(8) TextBox102.Text = szArray(9) Debug.WriteLine (szArray(innn)) Next
For mmm = 1 To 9 nineA(mmm) = mmm Next For mmm = 1 To 9 Do Dim rng As New Random j = rng.Next(1, 10) Loop Until nineA(j) > 0 nineA(j) = 0 szArray(mmm) = j TextBox85.Text = szArray(1) TextBox94.Text = szArray(2) TextBox103.Text = szArray(3) TextBox86.Text = szArray(4) TextBox95.Text = szArray(5) TextBox104.Text = szArray(6) TextBox87.Text = szArray(7) TextBox96.Text = szArray(8) TextBox105.Text = szArray(9) Debug.WriteLine (szArray(mmm)) Next
ne iideas? regards
nope. u have duplicate numbers in same column
Peter Proost wrote: Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this code, the makeGrid part is just to show the use of a textbox array
hth Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventAr gs) Handles MyBase.Load makeGrid() fillRandom() End Sub
Private Sub makeGrid() Dim x As TextBox Dim xPos, yPos As Integer yPos = 20 For row As Integer = 0 To 8 xPos = 20 For column As Integer = 0 To 1 x = New TextBox x.Name = (CStr(row) & CStr(column)) x.Location = New Point(xPos, yPos) x.BorderStyle = BorderStyle.Fix edSingle x.Width = 20 x.Height = 20 x.Text = "" Me.Controls.Add (x) textboxGrid(row , column) = x xPos += 21 Next yPos += 21 Next End Sub
Private Sub fillRandom() Dim blnOk As Boolean For row As Integer = 0 To 8 blnOk = False Do While blnOk = False textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1) textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1) If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then blnOk = True End If Loop Next End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventAr gs) Handles _ Button1.Click fillRandom() End Sub
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:AY******* *************@r ogers.com...
how do i get 2 different number in same row? using random example:
4 2 5 6 7 4 1 7 9 8 3 3 <===== i want different number but not same as opposite 8 5 6 8 2 1
in my code:
Dim Nine_numbers(9) as short Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short Dim j, k As Integer For innn = 1 To 9 nine(innn) = innn Next For innn = 1 To 9 Do Dim rng As New Random k = rng.Next(1, 10) Loop Until nine(k) > 0 nine(k) = 0 szArray(innn) = k TextBox82.Text = szArray(1) TextBox91.Text = szArray(2) TextBox100.Text = szArray(3) TextBox83.Text = szArray(4) TextBox92.Text = szArray(5) TextBox101.Text = szArray(6) TextBox84.Text = szArray(7) TextBox93.Text = szArray(8) TextBox102.Text = szArray(9) Debug.WriteLine (szArray(innn)) Next
For mmm = 1 To 9 nineA(mmm) = mmm Next For mmm = 1 To 9 Do Dim rng As New Random j = rng.Next(1, 10) Loop Until nineA(j) > 0 nineA(j) = 0 szArray(mmm) = j TextBox85.Text = szArray(1) TextBox94.Text = szArray(2) TextBox103.Text = szArray(3) TextBox86.Text = szArray(4) TextBox95.Text = szArray(5) TextBox104.Text = szArray(6) TextBox87.Text = szArray(7) TextBox96.Text = szArray(8) TextBox105.Text = szArray(9) Debug.WriteLine (szArray(mmm)) Next
ne iideas? regards
btw... i wanted random number from 1 to 9 in column and so on
Supra wrote: nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this code, the makeGrid part is just to show the use of a textbox array
hth Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventA rgs) Handles MyBase.Load makeGrid() fillRandom() End Sub
Private Sub makeGrid() Dim x As TextBox Dim xPos, yPos As Integer yPos = 20 For row As Integer = 0 To 8 xPos = 20 For column As Integer = 0 To 1 x = New TextBox x.Name = (CStr(row) & CStr(column)) x.Location = New Point(xPos, yPos) x.BorderStyle = BorderStyle.Fix edSingle x.Width = 20 x.Height = 20 x.Text = "" Me.Controls.Add (x) textboxGrid(row , column) = x xPos += 21 Next yPos += 21 Next End Sub
Private Sub fillRandom() Dim blnOk As Boolean For row As Integer = 0 To 8 blnOk = False Do While blnOk = False textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1) textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1) If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then blnOk = True End If Loop Next End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventA rgs) Handles _ Button1.Click fillRandom() End Sub
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:AY****** **************@ rogers.com...
how do i get 2 different number in same row? using random example:
4 2 5 6 7 4 1 7 9 8 3 3 <===== i want different number but not same as opposite 8 5 6 8 2 1
in my code:
Dim Nine_numbers(9) as short Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short Dim j, k As Integer For innn = 1 To 9 nine(innn) = innn Next For innn = 1 To 9 Do Dim rng As New Random k = rng.Next(1, 10) Loop Until nine(k) > 0 nine(k) = 0 szArray(innn) = k TextBox82.Text = szArray(1) TextBox91.Text = szArray(2) TextBox100.Text = szArray(3) TextBox83.Text = szArray(4) TextBox92.Text = szArray(5) TextBox101.Text = szArray(6) TextBox84.Text = szArray(7) TextBox93.Text = szArray(8) TextBox102.Text = szArray(9) Debug.WriteLine (szArray(innn)) Next
For mmm = 1 To 9 nineA(mmm) = mmm Next For mmm = 1 To 9 Do Dim rng As New Random j = rng.Next(1, 10) Loop Until nineA(j) > 0 nineA(j) = 0 szArray(mmm) = j TextBox85.Text = szArray(1) TextBox94.Text = szArray(2) TextBox103.Text = szArray(3) TextBox86.Text = szArray(4) TextBox95.Text = szArray(5) TextBox104.Text = szArray(6) TextBox87.Text = szArray(7) TextBox96.Text = szArray(8) TextBox105.Text = szArray(9) Debug.WriteLine (szArray(mmm)) Next
ne iideas? regards
you wrote: how do i get 2 different number in same row? using random example:
but it shouldn't be to difficult to alter my example
Greetz Peter
--
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:ZN******** ************@ro gers.com...
nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this
code, the makeGrid part is just to show the use of a textbox array
hth
Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
makeGrid()
fillRandom()
End Sub
Private Sub makeGrid()
Dim x As TextBox
Dim xPos, yPos As Integer
yPos = 20
For row As Integer = 0 To 8
xPos = 20
For column As Integer = 0 To 1
x = New TextBox
x.Name = (CStr(row) & CStr(column))
x.Location = New Point(xPos, yPos)
x.BorderStyle = BorderStyle.Fix edSingle
x.Width = 20
x.Height = 20
x.Text = ""
Me.Controls.Add (x)
textboxGrid(row , column) = x
xPos += 21
Next
yPos += 21
Next
End Sub
Private Sub fillRandom()
Dim blnOk As Boolean
For row As Integer = 0 To 8
blnOk = False
Do While blnOk = False
textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1)
textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1)
If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then
blnOk = True
End If
Loop
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles _ Button1.Click
fillRandom()
End Sub
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht
news:AY******** ************@ro gers.com...
how do i get 2 different number in same row? using random
example:
4 2
5 6
7 4
1 7
9 8
3 3 <===== i want different number but not same as opposite
8 5
6 8
2 1
in my code:
Dim Nine_numbers(9) as short
Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short
Dim j, k As Integer
For innn = 1 To 9
nine(innn) = innn
Next
For innn = 1 To 9
Do
Dim rng As New Random
k = rng.Next(1, 10)
Loop Until nine(k) > 0
nine(k) = 0
szArray(innn) = k
TextBox82.Text = szArray(1)
TextBox91.Text = szArray(2)
TextBox100.Text = szArray(3)
TextBox83.Text = szArray(4)
TextBox92.Text = szArray(5)
TextBox101.Text = szArray(6)
TextBox84.Text = szArray(7)
TextBox93.Text = szArray(8)
TextBox102.Text = szArray(9)
Debug.WriteLine (szArray(innn))
Next
For mmm = 1 To 9
nineA(mmm) = mmm
Next
For mmm = 1 To 9
Do
Dim rng As New Random
j = rng.Next(1, 10)
Loop Until nineA(j) > 0
nineA(j) = 0
szArray(mmm) = j
TextBox85.Text = szArray(1)
TextBox94.Text = szArray(2)
TextBox103.Text = szArray(3)
TextBox86.Text = szArray(4)
TextBox95.Text = szArray(5)
TextBox104.Text = szArray(6)
TextBox87.Text = szArray(7)
TextBox96.Text = szArray(8)
TextBox105.Text = szArray(9)
Debug.WriteLine (szArray(mmm))
Next
ne iideas?
regards
yes. but i random number in each column but compare row. what u do u
do random number have having same number in COLUMN but not in row not
ilike 775422133 in column but in order prevented same number in column
like i did previous code::
Loop Until (Nine_numbers3( inum3) > 0)
Nine_numbers3(i num3) = 0
szArray(n) = inum3
that is code will prevent same numbers. i was attempting subsistue in
ur sample code...
For row As Integer = 0 To 8
blnOk = False
Do
' blnOk = False
textboxGrid(row , 0).Text = Int(9 * Rnd() + 1)
' textboxGrid(row , 1).Text = Int(9 * Rnd() + 1)
' textboxGrid(row , 2).Text = Int(9 * Rnd() + 1)
' If textboxGrid(row , 0).Text <> textboxGrid(row ,
1).Text <> textboxGrid(row , 2).Text Then
' blnOk = True
' End If
Loop Until textboxGrid(row , 0).Text > 0
Next
but can't figuring it out..... i will have to work around.
regards,
Peter Proost wrote: you wrote:how do i get 2 different number in same row? using random example:
but it shouldn't be to difficult to alter my example
Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid <mailto:su***@d omain.invalid>> schreef in bericht news:ZN******** ************@ro gers.com... nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this code, the makeGrid part is just to show the use of a textbox array
hth Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventA rgs) Handles MyBase.Load makeGrid() fillRandom() End Sub
Private Sub makeGrid() Dim x As TextBox Dim xPos, yPos As Integer yPos = 20 For row As Integer = 0 To 8 xPos = 20 For column As Integer = 0 To 1 x = New TextBox x.Name = (CStr(row) & CStr(column)) x.Location = New Point(xPos, yPos) x.BorderStyle = BorderStyle.Fix edSingle x.Width = 20 x.Height = 20 x.Text = "" Me.Controls.Add (x) textboxGrid(row , column) = x xPos += 21 Next yPos += 21 Next End Sub
Private Sub fillRandom() Dim blnOk As Boolean For row As Integer = 0 To 8 blnOk = False Do While blnOk = False textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1) textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1) If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then blnOk = True End If Loop Next End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventA rgs) Handles _ Button1.Click fillRandom() End Sub
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:AY****** **************@ rogers.com...
how do i get 2 different number in same row? using random example:
4 2 5 6 7 4 1 7 9 8 3 3 <===== i want different number but not same as opposite 8 5 6 8 2 1
in my code:
Dim Nine_numbers(9) as short Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short Dim j, k As Integer For innn = 1 To 9 nine(innn) = innn Next For innn = 1 To 9 Do Dim rng As New Random k = rng.Next(1, 10) Loop Until nine(k) > 0 nine(k) = 0 szArray(innn) = k TextBox82.Text = szArray(1) TextBox91.Text = szArray(2) TextBox100.Text = szArray(3) TextBox83.Text = szArray(4) TextBox92.Text = szArray(5) TextBox101.Text = szArray(6) TextBox84.Text = szArray(7) TextBox93.Text = szArray(8) TextBox102.Text = szArray(9) Debug.WriteLine (szArray(innn)) Next
For mmm = 1 To 9 nineA(mmm) = mmm Next For mmm = 1 To 9 Do Dim rng As New Random j = rng.Next(1, 10) Loop Until nineA(j) > 0 nineA(j) = 0 szArray(mmm) = j TextBox85.Text = szArray(1) TextBox94.Text = szArray(2) TextBox103.Text = szArray(3) TextBox86.Text = szArray(4) TextBox95.Text = szArray(5) TextBox104.Text = szArray(6) TextBox87.Text = szArray(7) TextBox96.Text = szArray(8) TextBox105.Text = szArray(9) Debug.WriteLine (szArray(mmm)) Next
ne iideas? regards
Hi I'm going home now, but I'll try to help you 2morrow (I'm not sure if I'll have access to a .net computer tonight)
Greetz Peter
--
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:2I******** ************@ro gers.com...
yes. but i random number in each column but compare row. what u do u do random number have having same number in COLUMN but not in row not ilike 775422133 in column but in order prevented same number in column like i did previous code::
Loop Until (Nine_numbers3( inum3) > 0)
Nine_numbers3(i num3) = 0
szArray(n) = inum3
that is code will prevent same numbers. i was attempting subsistue in ur sample code...
For row As Integer = 0 To 8
blnOk = False
Do
' blnOk = False
textboxGrid(row , 0).Text = Int(9 * Rnd() + 1)
' textboxGrid(row , 1).Text = Int(9 * Rnd() + 1)
' textboxGrid(row , 2).Text = Int(9 * Rnd() + 1)
' If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text <> textboxGrid(row , 2).Text Then
' blnOk = True
' End If
Loop Until textboxGrid(row , 0).Text > 0
Next
but can't figuring it out..... i will have to work around.
regards,
Peter Proost wrote:
you wrote: how do i get 2 different number in same row? using random example:
but it shouldn't be to difficult to alter my example
Greetz Peter
--
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:ZN******** ************@ro gers.com...
nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this
code, the makeGrid part is just to show the use of a textbox array
hth
Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
makeGrid()
fillRandom()
End Sub
Private Sub makeGrid()
Dim x As TextBox
Dim xPos, yPos As Integer
yPos = 20
For row As Integer = 0 To 8
xPos = 20
For column As Integer = 0 To 1
x = New TextBox
x.Name = (CStr(row) & CStr(column))
x.Location = New Point(xPos, yPos)
x.BorderStyle = BorderStyle.Fix edSingle
x.Width = 20
x.Height = 20
x.Text = ""
Me.Controls.Add (x)
textboxGrid(row , column) = x
xPos += 21
Next
yPos += 21
Next
End Sub
Private Sub fillRandom()
Dim blnOk As Boolean
For row As Integer = 0 To 8
blnOk = False
Do While blnOk = False
textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1)
textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1)
If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then
blnOk = True
End If
Loop
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles _ Button1.Click
fillRandom()
End Sub
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht
news:AY******** ************@ro gers.com...
how do i get 2 different number in same row? using random
example:
4 2
5 6
7 4
1 7
9 8
3 3 <===== i want different number but not same as opposite
8 5
6 8
2 1
in my code:
Dim Nine_numbers(9) as short
Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short
Dim j, k As Integer
For innn = 1 To 9
nine(innn) = innn
Next
For innn = 1 To 9
Do
Dim rng As New Random
k = rng.Next(1, 10)
Loop Until nine(k) > 0
nine(k) = 0
szArray(innn) = k
TextBox82.Text = szArray(1)
TextBox91.Text = szArray(2)
TextBox100.Text = szArray(3)
TextBox83.Text = szArray(4)
TextBox92.Text = szArray(5)
TextBox101.Text = szArray(6)
TextBox84.Text = szArray(7)
TextBox93.Text = szArray(8)
TextBox102.Text = szArray(9)
Debug.WriteLine (szArray(innn))
Next
For mmm = 1 To 9
nineA(mmm) = mmm
Next
For mmm = 1 To 9
Do
Dim rng As New Random
j = rng.Next(1, 10)
Loop Until nineA(j) > 0
nineA(j) = 0
szArray(mmm) = j
TextBox85.Text = szArray(1)
TextBox94.Text = szArray(2)
TextBox103.Text = szArray(3)
TextBox86.Text = szArray(4)
TextBox95.Text = szArray(5)
TextBox104.Text = szArray(6)
TextBox87.Text = szArray(7)
TextBox96.Text = szArray(8)
TextBox105.Text = szArray(9)
Debug.WriteLine (szArray(mmm))
Next
ne iideas?
regards
have nice day trip :-)
Peter Proost wrote: Hi I'm going home now, but I'll try to help you 2morrow (I'm not sure if I'll have access to a .net computer tonight)
Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid <mailto:su***@d omain.invalid>> schreef in bericht news:2I******** ************@ro gers.com... yes. but i random number in each column but compare row. what u do u do random number have having same number in COLUMN but not in row not ilike 775422133 in column but in order prevented same number in column like i did previous code:: Loop Until (Nine_numbers3( inum3) > 0) Nine_numbers3(i num3) = 0 szArray(n) = inum3 that is code will prevent same numbers. i was attempting subsistue in ur sample code... For row As Integer = 0 To 8 blnOk = False Do ' blnOk = False textboxGrid(row , 0).Text = Int(9 * Rnd() + 1) ' textboxGrid(row , 1).Text = Int(9 * Rnd() + 1) ' textboxGrid(row , 2).Text = Int(9 * Rnd() + 1) ' If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text <> textboxGrid(row , 2).Text Then ' blnOk = True ' End If Loop Until textboxGrid(row , 0).Text > 0 Next but can't figuring it out..... i will have to work around. regards,
Peter Proost wrote:
you wrote: >how do i get 2 different number in same row? using random >example:
but it shouldn't be to difficult to alter my example
Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid <mailto:su***@d omain.invalid>> schreef in bericht news:ZN******** ************@ro gers.com... nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this code, the makeGrid part is just to show the use of a textbox array
hth Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.Event Args) Handles MyBase.Load makeGrid() fillRandom() End Sub
Private Sub makeGrid() Dim x As TextBox Dim xPos, yPos As Integer yPos = 20 For row As Integer = 0 To 8 xPos = 20 For column As Integer = 0 To 1 x = New TextBox x.Name = (CStr(row) & CStr(column)) x.Location = New Point(xPos, yPos) x.BorderStyle = BorderStyle.Fix edSingle x.Width = 20 x.Height = 20 x.Text = "" Me.Controls.Add (x) textboxGrid(row , column) = x xPos += 21 Next yPos += 21 Next End Sub
Private Sub fillRandom() Dim blnOk As Boolean For row As Integer = 0 To 8 blnOk = False Do While blnOk = False textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1) textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1) If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then blnOk = True End If Loop Next End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.Event Args) Handles _ Button1.Click fillRandom() End Sub
-- Programmin g today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:AY***** *************** @rogers.com...
how do i get 2 different number in same row? using random example:
4 2 5 6 7 4 1 7 9 8 3 3 <===== i want different number but not same as opposite 8 5 6 8 2 1
in my code:
Dim Nine_numbers(9) as short Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short Dim j, k As Integer For innn = 1 To 9 nine(innn) = innn Next For innn = 1 To 9 Do Dim rng As New Random k = rng.Next(1, 10) Loop Until nine(k) > 0 nine(k) = 0 szArray(innn) = k TextBox82.Text = szArray(1) TextBox91.Text = szArray(2) TextBox100.Text = szArray(3) TextBox83.Text = szArray(4) TextBox92.Text = szArray(5) TextBox101.Text = szArray(6) TextBox84.Text = szArray(7) TextBox93.Text = szArray(8) TextBox102.Text = szArray(9) Debug.WriteLine (szArray(innn)) Next
For mmm = 1 To 9 nineA(mmm) = mmm Next For mmm = 1 To 9 Do Dim rng As New Random j = rng.Next(1, 10) Loop Until nineA(j) > 0 nineA(j) = 0 szArray(mmm) = j TextBox85.Text = szArray(1) TextBox94.Text = szArray(2) TextBox103.Text = szArray(3) TextBox86.Text = szArray(4) TextBox95.Text = szArray(5) TextBox104.Text = szArray(6) TextBox87.Text = szArray(7) TextBox96.Text = szArray(8) TextBox105.Text = szArray(9) Debug.WriteLine (szArray(mmm)) Next
ne iideas? regards
Hi try it with this code in the fillrandom sub, it should work:
Private Sub fillRandom()
Dim left As New ArrayList
Dim right As New ArrayList
Dim blnOk As Boolean = False
Dim intGetal As Integer
For i As Integer = 0 To 8
blnOk = False
Do While blnOk = False
intGetal = CInt(Rnd() * 8) + 1
If left.IndexOf(in tGetal) < 0 Then
left.Add(intGet al)
blnOk = True
Else
blnOk = False
End If
Loop
Next
For i As Integer = 0 To 8
blnOk = False
Do While blnOk = False
intGetal = CInt(Rnd() * 8) + 1
If right.IndexOf(i ntGetal) < 0 And intGetal <> CInt(left(i)) Then
right.Add(intGe tal)
blnOk = True
Else
blnOk = False
End If
Loop
Next
For i As Integer = 0 To 8
textboxGrid(i, 0).Text = CStr(left(i))
textboxGrid(i, 1).Text = CStr(right(i))
Next
End Sub
hth Greetz Peter
--
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:38******** ************@ro gers.com...
have nice day trip :-)
Peter Proost wrote:
Hi I'm going home now, but I'll try to help you 2morrow (I'm not sure if I'll have access to a .net computer tonight)
Greetz Peter
--
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:2I******** ************@ro gers.com...
yes. but i random number in each column but compare row. what u do u do random number have having same number in COLUMN but not in row not ilike 775422133 in column but in order prevented same number in column like i did previous code::
Loop Until (Nine_numbers3( inum3) > 0)
Nine_numbers3(i num3) = 0
szArray(n) = inum3
that is code will prevent same numbers. i was attempting subsistue in ur sample code...
For row As Integer = 0 To 8
blnOk = False
Do
' blnOk = False
textboxGrid(row , 0).Text = Int(9 * Rnd() + 1)
' textboxGrid(row , 1).Text = Int(9 * Rnd() + 1)
' textboxGrid(row , 2).Text = Int(9 * Rnd() + 1)
' If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text <> textboxGrid(row , 2).Text Then
' blnOk = True
' End If
Loop Until textboxGrid(row , 0).Text > 0
Next
but can't figuring it out..... i will have to work around.
regards,
Peter Proost wrote:
you wrote: how do i get 2 different number in same row? using random example:
but it shouldn't be to difficult to alter my example
Greetz Peter
--
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:ZN******** ************@ro gers.com...
nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this
code, the makeGrid part is just to show the use of a textbox array
hth
Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
makeGrid()
fillRandom()
End Sub
Private Sub makeGrid()
Dim x As TextBox
Dim xPos, yPos As Integer
yPos = 20
For row As Integer = 0 To 8
xPos = 20
For column As Integer = 0 To 1
x = New TextBox
x.Name = (CStr(row) & CStr(column))
x.Location = New Point(xPos, yPos)
x.BorderStyle = BorderStyle.Fix edSingle
x.Width = 20
x.Height = 20
x.Text = ""
Me.Controls.Add (x)
textboxGrid(row , column) = x
xPos += 21
Next
yPos += 21
Next
End Sub
Private Sub fillRandom()
Dim blnOk As Boolean
For row As Integer = 0 To 8
blnOk = False
Do While blnOk = False
textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1)
textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1)
If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then
blnOk = True
End If
Loop
Next
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles _ Button1.Click
fillRandom()
End Sub
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht
news:AY******** ************@ro gers.com...
how do i get 2 different number in same row? using random
example:
4 2
5 6
7 4
1 7
9 8
3 3 <===== i want different number but not same as opposite
8 5
6 8
2 1
in my code:
Dim Nine_numbers(9) as short
Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short
Dim j, k As Integer
For innn = 1 To 9
nine(innn) = innn
Next
For innn = 1 To 9
Do
Dim rng As New Random
k = rng.Next(1, 10)
Loop Until nine(k) > 0
nine(k) = 0
szArray(innn) = k
TextBox82.Text = szArray(1)
TextBox91.Text = szArray(2)
TextBox100.Text = szArray(3)
TextBox83.Text = szArray(4)
TextBox92.Text = szArray(5)
TextBox101.Text = szArray(6)
TextBox84.Text = szArray(7)
TextBox93.Text = szArray(8)
TextBox102.Text = szArray(9)
Debug.WriteLine (szArray(innn))
Next
For mmm = 1 To 9
nineA(mmm) = mmm
Next
For mmm = 1 To 9
Do
Dim rng As New Random
j = rng.Next(1, 10)
Loop Until nineA(j) > 0
nineA(j) = 0
szArray(mmm) = j
TextBox85.Text = szArray(1)
TextBox94.Text = szArray(2)
TextBox103.Text = szArray(3)
TextBox86.Text = szArray(4)
TextBox95.Text = szArray(5)
TextBox104.Text = szArray(6)
TextBox87.Text = szArray(7)
TextBox96.Text = szArray(8)
TextBox105.Text = szArray(9)
Debug.WriteLine (szArray(mmm))
Next
ne iideas?
regards
:-)
Peter Proost wrote: Hi try it with this code in the fillrandom sub, it should work:
Private Sub fillRandom() Dim left As New ArrayList Dim right As New ArrayList Dim blnOk As Boolean = False Dim intGetal As Integer For i As Integer = 0 To 8 blnOk = False Do While blnOk = False intGetal = CInt(Rnd() * 8) + 1 If left.IndexOf(in tGetal) < 0 Then left.Add(intGet al) blnOk = True Else blnOk = False End If Loop Next For i As Integer = 0 To 8 blnOk = False Do While blnOk = False intGetal = CInt(Rnd() * 8) + 1 If right.IndexOf(i ntGetal) < 0 And intGetal <> CInt(left(i)) Then right.Add(intGe tal) blnOk = True Else blnOk = False End If Loop Next
For i As Integer = 0 To 8 textboxGrid(i, 0).Text = CStr(left(i)) textboxGrid(i, 1).Text = CStr(right(i)) Next
End Sub
hth Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid <mailto:su***@d omain.invalid>> schreef in bericht news:38******** ************@ro gers.com... have nice day trip :-)
Peter Proost wrote:
Hi I'm going home now, but I'll try to help you 2morrow (I'm not sure if I'll have access to a .net computer tonight)
Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid <mailto:su***@d omain.invalid>> schreef in bericht news:2I******** ************@ro gers.com... yes. but i random number in each column but compare row. what u do u do random number have having same number in COLUMN but not in row not ilike 775422133 in column but in order prevented same number in column like i did previous code:: Loop Until (Nine_numbers3( inum3) > 0) Nine_numbers3(i num3) = 0 szArray(n) = inum3 that is code will prevent same numbers. i was attempting subsistue in ur sample code... For row As Integer = 0 To 8 blnOk = False Do ' blnOk = False textboxGrid(row , 0).Text = Int(9 * Rnd() + 1) ' textboxGrid(row , 1).Text = Int(9 * Rnd() + 1) ' textboxGrid(row , 2).Text = Int(9 * Rnd() + 1) ' If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text <> textboxGrid(row , 2).Text Then ' blnOk = True ' End If Loop Until textboxGrid(row , 0).Text > 0 Next but can't figuring it out..... i will have to work around. regards,
Peter Proost wrote:
you wrote: >how do i get 2 different number in same row? using random >example:
but it shouldn't be to difficult to alter my example
Greetz Peter
-- Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid <mailto:su***@d omain.invalid>> schreef in bericht news:ZN******** ************@ro gers.com... nope. u have duplicate numbers in same column
Peter Proost wrote:
Hi,
there probably will be better ways but this does seem to do the trick for me
just open a new windows forms project add a button to it and copy paste this code, the makeGrid part is just to show the use of a textbox array
hth Greetz Peter
Private textboxGrid(8, 1) As TextBox
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.Even tArgs) Handles MyBase.Load makeGrid() fillRandom() End Sub
Private Sub makeGrid() Dim x As TextBox Dim xPos, yPos As Integer yPos = 20 For row As Integer = 0 To 8 xPos = 20 For column As Integer = 0 To 1 x = New TextBox x.Name = (CStr(row) & CStr(column)) x.Location = New Point(xPos, yPos) x.BorderStyle = BorderStyle.Fix edSingle x.Width = 20 x.Height = 20 x.Text = "" Me.Controls.Add (x) textboxGrid(row , column) = x xPos += 21 Next yPos += 21 Next End Sub
Private Sub fillRandom() Dim blnOk As Boolean For row As Integer = 0 To 8 blnOk = False Do While blnOk = False textboxGrid(row , 0).Text = CStr(CInt(Rnd() * 9) + 1) textboxGrid(row , 1).Text = CStr(CInt(Rnd() * 9) + 1) If textboxGrid(row , 0).Text <> textboxGrid(row , 1).Text Then blnOk = True End If Loop Next End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.Even tArgs) Handles _ Button1.Click fillRandom() End Sub
-- Programmi ng today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Supra" <su***@domain.i nvalid> schreef in bericht news:AY**** *************** *@rogers.com...
>how do i get 2 different number in same row? using random >example: > >4 2 >5 6 >7 4 >1 7 >9 8 >3 3 <===== i want different number but not same as opposite >8 5 >6 8 >2 1 > >in my code: > >Dim Nine_numbers(9) as short > Dim nm, mm As Integer, nine(9), nineA(9) As Object, innn, mmm As Short > Dim j, k As Integer > For innn = 1 To 9 > nine(innn) = innn > Next > For innn = 1 To 9 > Do > Dim rng As New Random > k = rng.Next(1, 10) > Loop Until nine(k) > 0 > nine(k) = 0 > szArray(innn) = k > TextBox82.Text = szArray(1) > TextBox91.Text = szArray(2) > TextBox100.Text = szArray(3) > TextBox83.Text = szArray(4) > TextBox92.Text = szArray(5) > TextBox101.Text = szArray(6) > TextBox84.Text = szArray(7) > TextBox93.Text = szArray(8) > TextBox102.Text = szArray(9) > Debug.WriteLine (szArray(innn)) > Next > > For mmm = 1 To 9 > nineA(mmm) = mmm > Next > For mmm = 1 To 9 > Do > Dim rng As New Random > j = rng.Next(1, 10) > Loop Until nineA(j) > 0 > nineA(j) = 0 > szArray(mmm) = j > TextBox85.Text = szArray(1) > TextBox94.Text = szArray(2) > TextBox103.Text = szArray(3) > TextBox86.Text = szArray(4) > TextBox95.Text = szArray(5) > TextBox104.Text = szArray(6) > TextBox87.Text = szArray(7) > TextBox96.Text = szArray(8) > TextBox105.Text = szArray(9) > Debug.WriteLine (szArray(mmm)) > Next > >ne iideas? >regards > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alexander N. Spitzer |
last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how
can I start 3 instances of the same RMI application (each started with
different properties/configs), each listening on the port 1234, but each
instance binds to a different ip address.
that is to say:
instance #1 binds to 192.168.1.5/port 1234
instance #2 binds to...
|
by: Philippe C. Martin |
last post by:
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).
- 1) I do not consider my intelligence/education above average
- 2) I am very pragmatic
- 3) I usually move forward when I get the gut feeling I am correct
- 4) Most likely because of 1), I usually do not manage to fully explain...
|
by: Gaijinco |
last post by:
Sooner or later everytime I found recreational programming challenges I
stumble with how I test if a number is has decimal places differnt than
0?
For example if I want to know if a number is a square number (i.e. a
number which square root is a positive number as 4, 9, 16 have) I do
something like:
int square = sqrt(number);
|
by: Wilfried |
last post by:
Hi,
I have 5 tables:
main
data1
|
by: Brian |
last post by:
I hv a school assignment that is to generate 52 different random
number, where all the numbers must >1 and <53. Pls help~
Thanks~
| |
by: davidkoree |
last post by:
I mean not about cookie.
Does it have something to do with operating system or browser plugin?
I appreciate any help.
|
by: Masud |
last post by:
hi,
for a test i want to generate different random numbers between
different ranges in a single loop. I tried to solve in the following
way but it always profile same value. I am looking for suggestion in
this regard.
#include <cstdlib>
#include <time.h>
#include<iostream.h>
|
by: Chiefy |
last post by:
Im writing in C# and I currently have a class called allocation that has random numbers like,
students.choiceTwo = Randnum.Next(15);
obviously using the Random class. The random numbers are part of a method called Allocate.
In my main method i have created 2 instances of the class
Allocation first = new Allocation();
Allocation second = new...
|
by: raylopez99 |
last post by:
Here are two different ways of achieving a mediator pattern: the
first, using circular references (for lack of a better way to describe
it), but not using delegates, with the second using delegates.
The first way is an adaptation from C++ for Dummies by Jeff Cogswell.
But obviously it uses references not pointers.
The second way (I'll...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |