Hi all,
I am fairly new to vb.net so this question will certainly sound stupid, but I've been stock with it for the last week so any help is much appreciated.
the form includes 3 picture boxes in red which you can click and change their color to green, also each picture box have three text box asscoiate with it and they are by default color dark gray. I want the system to check whether the picture boxes are clicked and if yes set the associated text box colours to white. here is the code I wrote:
Thanks in advance!
I am fairly new to vb.net so this question will certainly sound stupid, but I've been stock with it for the last week so any help is much appreciated.
the form includes 3 picture boxes in red which you can click and change their color to green, also each picture box have three text box asscoiate with it and they are by default color dark gray. I want the system to check whether the picture boxes are clicked and if yes set the associated text box colours to white. here is the code I wrote:
Code:
Public Class Screen
Inherits Windows.Forms.Form
Dim T(1, 2) As TextBox
Dim S(2) As PictureBox
Dim x, i, j As Integer
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S1.Click
S1.BackColor = Color.Green
End Sub
Private Sub S2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S2.Click
S2.BackColor = Color.Green
End Sub
Private Sub S3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S3.Click
S3.BackColor = Color.Green
End Sub
Public Function checkedS() As Boolean
If S1.BackColor = Color.Green Then
Return True
ElseIf S2.BackColor = Color.Green Then
Return True
ElseIf S3.BackColor = Color.Green Then
Return True
ElseIf S1.BackColor = Color.Red Then
Return False
End If
End Function
Public Function findS() As Integer
If checkedS() = True Then
If S1.BackColor = Color.Green Then
x = 0
ElseIf S2.BackColor = Color.Green Then
x = 1
ElseIf S3.BackColor = Color.Green Then
x = 2
End If
Return x
End If
End Function
Public Sub setroute()
t(0, 0) = TextBox1
t(0, 1) = TextBox2
t(0, 2) = TextBox3
t(1, 0) = TextBox4
t(1, 1) = TextBox5
t(1, 2) = TextBox6
x = findS()
Do Until i = 3
t(x, i).BackColor = Color.White
i = i + 1
Loop
End Sub
Public Sub Screen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If checkedS() = True Then
setroute()
End If
End Sub
End Class
Thanks in advance!
Comment