Question : use variable to load text boxes.

How can loop and load text boxes using variables.  thanks

I have attached my code that dose not work
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
Dim cmd3 As New SqlClient.SqlDataAdapter("Select *   from tblPatientNote where lngPatientid  = '" & lngpatientid & "' order by bytNote, dtmcreate desc", Connection1)
        Dim countnotes As Integer
        Dim note, strnote, strcreate, memnote, dtmcreate, notebc, notev, strnotev, strcreatev, memnotev, dtmcreatev
        Try
            countnotes = cmd3.Fill(dsNotes, "tblPatientNote")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Do While i <> countnotes
            note = note & i & ".Text"
            notebc = note & i & ".BackColor"
            strnote = strnote & i & ".Text"
            strcreate = strcreate & i & ".Text"
            memnote = memnote & i & ".Text"
            dtmcreate = dtmcreate & i & ".Text"
            notev = note & i & ".visible"
            strnotev = strnote & i & ".visible"
            strcreatev = strcreate & i & ".visible"
            memnotev = memnote & i & ".visible"
            dtmcreatev = dtmcreate & i & ".visible"
            'add to notes and make each visible
            If IsDBNull(dsNotes.Tables("tblPatientNote").Rows(i).Item("bytnote")) = False Then
                If (dsNotes.Tables("tblPatientNote").Rows(i).Item("bytnote")) = "1" Then
                    notebc = System.Drawing.Color.Red
                    note = (dsNotes.Tables("tblPatientNote").Rows(i).Item("bytnote"))
                Else
                    notebc = System.Drawing.Color.White
                End If
                strnotev = True
                strcreatev = True
                memnotev = True
                dtmcreatev = True
                notev = True
            End If
            If IsDBNull(dsNotes.Tables("tblPatientNote").Rows(i).Item("strnote")) = False Then
                strnote = (dsNotes.Tables("tblPatientNote").Rows(i).Item("strnote"))

            End If
        
            If IsDBNull(dsNotes.Tables("tblPatientNote").Rows(i).Item("memnote")) = False Then
                memnote = (dsNotes.Tables("tblPatientNote").Rows(i).Item("memnote"))
            End If
            If IsDBNull(dsNotes.Tables("tblPatientNote").Rows(i).Item("dtmcreate")) = False Then
                dtmcreate = (dsNotes.Tables("tblPatientNote").Rows(i).Item("dtmcreate"))
            End If
            If IsDBNull(dsNotes.Tables("tblPatientNote").Rows(i).Item("strcreate")) = False Then
                strcreate = (dsNotes.Tables("tblPatientNote").Rows(i).Item("strcreate"))
            End If
            i = i + 1
        Loop
    End Sub

Answer : use variable to load text boxes.

Try something like this (example only):
1:
note = Ctype(Me.Controls(note & i.ToString()), TextBox).Text
Random Solutions  
 
programming4us programming4us