Referencing controls in code

Thanks, you sample of a hashtable makes more sense than the stuff I read on it last night. However, when I run the VB snippet above all I get at the h.add line is 'object referenc not set to an instance of an object'
 
Oh by the way,

Messagebox.Show(Controls.IndexOf(Me.txtDueDate))

returns -1, control not found!
 
Mmm helps if I type correctly !!!!

Missed the New statement.....DOH.

However I now get the same error on the directcast line?
 
AT LAST!!!!

For those of you how are interested, probably not but here you go:

Visual Basic:
 Dim htHash As New Hashtable()
 Dim pnlPanel, tbcTabControl, tbpTabPage, ctlControl As Object
 Dim intX As Integer

 For Each pnlPanel In Me.Controls

       For Each tbcTabControl In pnlPanel.Controls

             For Each tbpTabPage In tbcTabControl.Controls

                    For Each ctlControl In tbpTabPage.Controls

                          htHash.Add(ctlControl.Name, ctlControl)

                    Next

             Next

       Next

  Next

  For intX = 1 To 12

      DirectCast(htHash("txtDueDate" & intX), Control).Text = "HELLO"

 Next

THANX Divil :-)
 
Last edited by a moderator:
Back
Top