In my code I disable an array of lables and other two of textboxes. Then, depending on the val(text) of a textbox, which in not an element of the arrays, I need to enable labels and textboxes up to that val(text) bound. Therefore, I put that enabling code under a TextBox3.LostFocus procedure ( Textbox3 is that one out of the array). But the code, I mean: I am, not doing the job. Unsuccessfuly, I have tried different arrays dimensions to make the elements valid regardless the procedure where they were built. The code is below. Any help to solve this will be appreciated.
]
Thanks a lot
Nelson
HTML Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TextBox3.Text = String.Format("{00:n2}", aNumber)
Dim p As New Point
Static tX(0 To 39) As TextBox, tY(0 To 39) As TextBox, lb(0 To 39) As Label
'CENTER TITLE
p.X = (Me.Width - Label1.Width) / 2
p.Y = Label1.Top
Label1.Location = p
RectangleShape1.Left = (Me.Width - RectangleShape1.Width) \ 2
'LOCATE PICTURE BUTTONS CONTAINER
RectangleShape8.Left = RectangleShape3.Right + 270
RectangleShape9.Left = 80
RectangleShape9.Top = 30
'LOCATE PICTURE BUTTONS
PictureBox1.Left = RectangleShape8.Left + 10
PictureBox2.Left = RectangleShape8.Left + 10
PictureBox3.Left = RectangleShape8.Left + 10
PictureBox4.Left = RectangleShape8.Left + 10
PictureBox5.Left = RectangleShape8.Left + 10
PictureBox6.Left = RectangleShape8.Left + 10
PictureBox7.Left = RectangleShape8.Left + 10
PictureBox8.Left = RectangleShape9.Left + 13
PictureBox8.Top = RectangleShape9.Top + 10
'LOCATE LOGO
PictureBox9.Left = Me.Left + 13
PictureBox9.Top = Me.Top + 570
'CENTER BASIC DATA FRAME
RectangleShape2.Left = (Me.Width - RectangleShape2.Width) \ 2
'LOCATE BASIC DATA LABELS
Label2.Left = RectangleShape2.Left + 25
Label4.Left = RectangleShape2.Left + 25
Label3.Left = RectangleShape2.Left + 390
Label5.Left = RectangleShape2.Left + 390
'LOCATE BASIC DATA FIELDS
TextBox1.Left = RectangleShape2.Left + 180
TextBox3.Left = RectangleShape2.Left + 180
TextBox2.Left = RectangleShape2.Left + 545
ComboBox1.Left = RectangleShape2.Left + 545
'CENTER VERTICES GENERAL CONTAINER
RectangleShape3.Left = (Me.Width - RectangleShape3.Width) \ 2
'LOCATE VERTICES INDIVIDUAL CONTAINERS
RectangleShape4.Left = RectangleShape3.Left + 30
RectangleShape5.Left = RectangleShape3.Left + 250
RectangleShape6.Left = RectangleShape3.Left + 470
RectangleShape7.Left = RectangleShape3.Left + 690
'LOCATE VERTEX COLUMNS HEADS
Label46.Left = RectangleShape4.Left + 116
Label47.Left = RectangleShape5.Left + 116
Label48.Left = RectangleShape6.Left + 116
Label49.Left = RectangleShape7.Left + 116
Label50.Left = RectangleShape4.Left + 164
Label51.Left = RectangleShape5.Left + 164
Label52.Left = RectangleShape6.Left + 164
Label53.Left = RectangleShape7.Left + 164
' LABEL & COORDINATE ARRAY
Dim t As Integer, c As Integer, w As Integer, m As Integer, n As Integer, h As Integer, o As Integer, l As Integer, z As Integer
For i = 0 To 39
lb(i) = New Label
tX(i) = New TextBox
tY(i) = New TextBox
Next
'BASE OF LOCATION
z = RectangleShape4.Top
w = RectangleShape4.Left
'TOP ROOM
t = 30
'LEFT ROOM
m = 10 'LABELS
n = 105 'tX
o = 153 'tY
l = 0 'Locate array elements, base of counting
h = 9 'Elements Top Location
c = 1 'Change Marker
While c < 5
For i = l To h
'TEXTBOX TEXT, LOCATION & PROPERTIES
lb(i).Text = "Vértice " + (i + 1).ToString
lb(i).Anchor = AnchorStyles.Top
lb(i).Anchor = AnchorStyles.Left
lb(i).Top = z + t
lb(i).Left = w + m
lb(i).Size = New System.Drawing.Size(86, 25)
lb(i).BorderStyle = System.Windows.Forms.BorderStyle.None
lb(i).Font = New System.Drawing.Font("Arial", 12.0F, System.Drawing.FontStyle.Bold)
lb(i).Enabled = False
lb(i).BackColor = Color.FromArgb(255, 221, 217, 195)
'TEXTBOX TX LOCATION & PROPERTIES
tX(i).Anchor = AnchorStyles.Top
tX(i).Anchor = AnchorStyles.Left
tX(i).Top = z + t
tX(i).Left = w + n
tX(i).Size = New System.Drawing.Size(40, 15)
tX(i).BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
tX(i).Font = New System.Drawing.Font("Arial", 12.0F, System.Drawing.FontStyle.Bold)
tX(i).Enabled = False
tX(i).BackColor = Color.FromArgb(255, 217, 217, 217)
'TEXTBOX TY LOCATION & PROPERTIES
tY(i).Anchor = AnchorStyles.Top
tY(i).Anchor = AnchorStyles.Left
tY(i).Top = z + t
tY(i).Left = w + o
tY(i).Size = New System.Drawing.Size(40, 15)
tY(i).BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
tY(i).Font = New System.Drawing.Font("Arial", 12.0F, System.Drawing.FontStyle.Bold)
tY(i).Enabled = False
tY(i).BackColor = Color.FromArgb(255, 217, 217, 217)
'SHOW LABEL & TEXTBOX
Me.Controls.Add(lb(i))
Me.Controls.Add(tX(i))
Me.Controls.Add(tY(i))
t = t + 32
Next
t = 15
c = c + 1
If c = 2 Then
'BASE OF LOCATION
z = RectangleShape5.Top
w = RectangleShape5.Left
'TOP ROOM
t = 30
'LEFT ROOM
m = 10 'LABELS
n = 105 'tX
o = 153 'tY
l = 10 'Locate array elements, base of counting
h = 19 'Elements Top Location
End If
If c = 3 Then
'BASE OF LOCATION
z = RectangleShape6.Top
w = RectangleShape6.Left
'TOP ROOM
t = 30
'LEFT ROOM
m = 10 'LABELS
n = 105 'tX
o = 153 'tY
l = 20 'Locate array elements, base of counting
h = 29 'Elements Top Location
End If
If c = 4 Then
'BASE OF LOCATION
z = RectangleShape7.Top
w = RectangleShape7.Left
'TOP ROOM
t = 30
'LEFT ROOM
m = 10 'LABELS
n = 105 'tX
o = 153 'tY
l = 30 'Locate array elements, base of counting
h = 39 'Elements Top Location
End If
End While
'EMPTY VARIABLES
c = Nothing
t = Nothing
w = Nothing
m = Nothing
n = Nothing
o = Nothing
l = Nothing
h = Nothing
End Sub
Private Sub TextBox3_Lostfocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.LostFocus
'VALIDA CANTIDAD DE VERTICES
Dim vertices As Single
vertices = Val(TextBox3.Text)
'DISABLE VERTICE´S LABELS & TEXTBOXES
For i = 0 To 39
lb(i).Enabled = False
tX(i).Text = ""
tX(i).Enabled = False
tY(i).Enabled = False
lb(i).BackColor = Color.FromArgb(255, 217, 217, 217)
tX(i).BackColor = Color.FromArgb(255, 217, 217, 217)
tY(i).BackColor = Color.FromArgb(255, 217, 217, 217)
Controls.Add(lb(i))
Controls.Add(tX(i))
Controls.Add(tY(i))
Next
'ENABLE VERTICE´S LABELS & TEXTBOXES ACCORDING TO VERTICES
For i = 0 To vertices
lb(i).Enabled = True
tX(i).Enabled = True
tY(i).Enabled = True
lb(i).BackColor = Color.FromArgb(255, 221, 217, 195)
tX(i).BackColor = Color.FromArgb(255, 255, 255, 255)
tY(i).BackColor = Color.FromArgb(255, 255, 255, 255)
Controls.Add(lb(i))
Controls.Add(tX(i))
Controls.Add(tY(i))
Next
'VERTEX QUANTITY VALIDATE
If vertices < 3 Then
MsgBox("Cantidad de Vértices DEBE estar MAYOR que 2 y MENOR que 41", MsgBoxStyle.Critical, "ALERTA")
TextBox3.Text = ""
TextBox3.Focus()
'DISABLE VERTICE´S LABELS & TEXTBOXES ACCORDING TO VERTICES
For i = 0 To 39
lb(i).Enabled = False
tX(i).Text = ""
tX(i).Enabled = False
tY(i).Enabled = False
lb(i).BackColor = Color.FromArgb(255, 217, 217, 217)
tX(i).BackColor = Color.FromArgb(255, 217, 217, 217)
tY(i).BackColor = Color.FromArgb(255, 217, 217, 217)
Next
End If
End SubThanks a lot
Nelson