Hi
There are several things that would prevent a conversion.
- There are unidentified variables withing the code
- There are unidentified functions/subs invoked within the code.
However, based on partial understanding of the code, maybe this will help.
Start a new test Project and in the Designer, put a Panel25 containing some CheckBoxes named numerically, outside the Panel, on the Form, put a Textbox named 'TextBoxN' where N corresponds to a CheckBox and finally a Button. (see image below)
Run the code and Check or Uncheck some CheckBoxes and click Button and watch if corresponding TextBox(s) follow desired effect.
This code has NO EXCEPTION CHECKING.
' default Form1 with:
' Panel25 containing some number of CheckBoxes
' with numeric names
' Corresponding number of TextBoxes
' Button1 to do operation
Option Strict On
Option Explicit On
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' set all TextBoxes to default
For Each c As Control In Me.Controls
Dim tb As TextBox = TryCast(c, TextBox)
If Not tb Is Nothing Then
With tb
.Text = String.Empty
.BackColor = Color.White
.ForeColor = Color.Black
End With
End If
Next
' search for Checked CheckBoxes and
' set corresponding TextBox properties
For Each c As Control In Panel25.Controls
If c.GetType = GetType(CheckBox) Then
If DirectCast(c, CheckBox).Checked Then
Dim n As Integer = 0
If Integer.TryParse(c.Text, n) Then
Dim tbn As String = "TextBox" & n.ToString
Dim cont() As Control = Me.Controls.Find(tbn, False)
Dim tb As TextBox = DirectCast(cont(0), TextBox)
With tb
.Text = n.ToString
.BackColor = Color.Blue
.ForeColor = Color.Yellow
End With
End If
End If
End If
Next
End Sub
End Class