Originally posted by SammyB
Declaration expected
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim NoOfElements As Integer, I As Integer, J As Integer, Temp As Integer
NoOfElements = 6
For I = 1 To (NoOfElements - 1)
For J = I To (NoOfElements - 1)
If x(I - 1) > x(J) Then
Temp = x(I - 1)
x(I - 1) = x(J)
x(J) = Temp
End If
Next J
Next I
Button3.Text = x(0)
Button4.Text = x(1)
Button5.Text = x(2)
Button6.Text = x(3)
Button7.Text = x(4)
Button8.Text = x(5)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim NoOfElements As Integer, I As Integer, J As Integer, Temp As Integer
NoOfElements = 6
For I = 1 To (NoOfElements - 1)
For J = I To (NoOfElements - 1)
If x(I - 1) > x(J) Then
Temp = x(I - 1)
x(I - 1) = x(J)
x(J) = Temp
End If
Next J
Next I
Button3.Text = x(0)
Button4.Text = x(1)
Button5.Text = x(2)
Button6.Text = x(3)
Button7.Text = x(4)
Button8.Text = x(5)
Class Form1
Dim x As Integer() = New Integer(20) {}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim m_blnUsed As Boolean() = _
New Boolean(x.GetUpperBound(0)) {}
Dim objrandom As Random = New Random()
Dim intrandom As Integer
Dim index As Integer
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
For index = 0 To 5
x(index) = intrandom
Next
Button3.Text = Str(x(0))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
For index = 0 To 5
x(index) = intrandom
Next
Button4.Text = Str(x(1))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
For index = 0 To 5
x(index) = intrandom
Next
Button5.Text = Str(x(2))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
For index = 0 To 5
x(index) = intrandom
Next
Button6.Text = Str(x(3))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
For index = 0 To 5
x(index) = intrandom
Next
Button7.Text = Str(x(4))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
For index = 0 To 5
x(index) = intrandom
Next
Button8.Text = Str(x(5))
Label2.Text = ""
Label3.Text = ""
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click
Dim index As Integer = sender.ToString.IndexOf(":") + 2
Dim btnName As Object = sender.ToString.Substring(index)
If Label2.Text = "" Then
'load the name from btnName into the Text property of the Label
Label2.Text = btnName
ElseIf Label3.Text = "" Then
'load the name from btnName into the Text property of the Label
Label3.Text = btnName
ElseIf Label4.Text = "" Then
'load the name from btnName into the Text property of the Label
Label4.Text = btnName
ElseIf Label5.Text = "" Then
'load the name from btnName into the Text property of the Label
Label5.Text = btnName
ElseIf Label6.Text = "" Then
'load the name from btnName into the Text property of the Label
Label6.Text = btnName
ElseIf Label7.Text = "" Then
'load the name from btnName into the Text property of the Label
Label7.Text = btnName
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Array.Sort(x)
Button3.Text = x(0)
Button4.Text = x(1)
Button5.Text = x(2)
Button6.Text = x(3)
Button7.Text = x(4)
Button8.Text = x(5)
End Sub
End Class
For index = 0 To 5
x(index) = intrandom
Next
For Index = [I]each element of [B]x()[/B] array[/I]
Start loop
Generate a random number
If it doesn’t match any entry in the array, Then
Place the value in x(Index)
Exit the loop
End If
End Loop
Next
For index = 0 To 5
x(index) = intrandom
Next
For Index = [I]each element of [B]x()[/B] array[/I]
Start loop
Generate a random number
If it doesn’t match any entry in the array, Then
Place the value in x(Index)
Exit the loop
End If
End Loop
Next
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim index As Integer, randomgenerator As New Random, computerchoice As Integer
For index = 0 To 5
Do While computerchoice = randomgenerator.Next(0, 19)
If computerchoice <> x(index) Then
x(index) = computerchoice
End If
Loop
Next
Button3.Text = Str(x(0))
Button4.Text = Str(x(1))
Button5.Text = Str(x(2))
Button6.Text = Str(x(3))
Button7.Text = Str(x(4))
Button8.Text = Str(x(5))
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim index As Integer, randomgenerator As New Random, computerchoice As Integer
For index = 0 To 5
computerchoice = randomgenerator.Next(0, 19)
If computerchoice <> x(index) Then
x(index) = computerchoice
End If
Next
Button3.Text = Str(x(0))
Button4.Text = Str(x(1))
Button5.Text = Str(x(2))
Button6.Text = Str(x(3))
Button7.Text = Str(x(4))
Button8.Text = Str(x(5))
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim index As Integer, randomgenerator As New Random, computerchoice As Integer
For index = 0 To 5
[B]Do While computerchoice = randomgenerator.Next(0, 19)[/B]
If computerchoice <> x(index) Then
x(index) = computerchoice
End If
Loop
Next
For index = 0 To 5
Do While index <= 5
computerchoice = randomgenerator.Next(0, 21)
If computerchoice <> x(index) Then
x(index) = computerchoice
End If
Loop
Next
For Index = x To y
[B]Do[/B]
Generate random number
Look for it in the array
[B]If[/B] not found
Add it to the array
Exit Do
[B]End If[/B]
[B]Loop[/B]
Next
For Index = x To y
[B]Do[/B]
Generate random number
Look for it in the array
[B]If[/B] not found
Add it to the array
Exit Do
[B]End If[/B]
[B]Loop[/B]
Next
Public Class Form1
Dim x As Integer() = New Integer(5) {}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "Select in ascending order by clicking on the numbers"
Label1.BackColor = Color.Empty
Dim m_blnUsed As Boolean() = _
New Boolean(20) {}
Dim objrandom As Random = New Random()
Dim intrandom As Integer
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
'add the random value into the x array
x(0) = intrandom
Button3.Text = Str(x(0))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
'add the random value into the x array
x(1) = intrandom
Button4.Text = Str(x(1))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
'add the random value into the x array
x(2) = intrandom
Button5.Text = Str(x(2))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
'add the random value into the x array
x(3) = intrandom
Button6.Text = Str(x(3))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
'add the random value into the x array
x(4) = intrandom
Button7.Text = Str(x(4))
Do
intrandom = objrandom.Next(0, m_blnUsed.Length)
Loop Until m_blnUsed(intrandom) = False
m_blnUsed(intrandom) = True
'add the random value into the x array
x(5) = intrandom
Button8.Text = Str(x(5))
Label2.Text = ""
Label3.Text = ""
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click
Dim index As Integer = sender.ToString.IndexOf(":") + 2
Dim btnName As Object = sender.ToString.Substring(index)
If Label2.Text = "" Then
'load the name from btnName into the Text property of the Label
Label2.Text = btnName
ElseIf Label3.Text = "" Then
'load the name from btnName into the Text property of the Label
Label3.Text = btnName
ElseIf Label4.Text = "" Then
'load the name from btnName into the Text property of the Label
Label4.Text = btnName
ElseIf Label5.Text = "" Then
'load the name from btnName into the Text property of the Label
Label5.Text = btnName
ElseIf Label6.Text = "" Then
'load the name from btnName into the Text property of the Label
Label6.Text = btnName
ElseIf Label7.Text = "" Then
'load the name from btnName into the Text property of the Label
Label7.Text = btnName
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Array.Sort(x)
Button3.Text = x(0)
Button4.Text = x(1)
Button5.Text = x(2)
Button6.Text = x(3)
Button7.Text = x(4)
Button8.Text = x(5)
If Label2.Text = Button3.Text And Label3.Text = Button4.Text And Label4.Text = Button5.Text And Label5.Text = Button6.Text And Label6.Text = Button7.Text And Label7.Text = Button8.Text Then
Label1.Text = "Correct, well done!"
Label1.BackColor = Color.Green
Else
Label1.Text = "Sorry, incorrect!"
Label1.BackColor = Color.Red
End If
End Sub
End Class
Comment