Try this instead:
Private msklist As New List(Of MaskedTextBox)
' Loop through all controls in form
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is Panel Then
' Loop through each of the controls in the Panel
For Each panelCtrl As Control In ctrl.Controls
If TypeOf panelCtrl Is MaskedTextBox Then
msklist.Add(panelCtrl)
End If
Next
End If
Next
MsgBox(msklist.Count)
' Get the text value once and apply it to each text box
query = "SELECT * FROM allotment_table"
cmd = New SqlCommand(query, con)
con.Open()
re = cmd.ExecuteReader
re.Read()
Dim textValue As String = re("regno")
con.Close()
' Loop through the list of masked text boxes and apply the text value to each
For Each mskTextBox As MaskedTextBox In msklist
mskTextBox.Text = textValue
Next