codice:
<form id="form1" runat="server">
<div id = "DivProva">
<asp:CheckBox ID="Chk1" runat="server" Text="Uno" />
<asp:CheckBox ID="Chk2" runat="server" Text="Due" />
<asp:CheckBox ID="Chk3" runat="server" Text="Tre" />
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="Txt1" runat="server"></asp:TextBox>
</div>
</form>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim IDs As String = String.Empty
For Each CTRL As Control In form1.Controls
If TypeOf (CTRL) Is CheckBox Then
If DirectCast(CTRL, CheckBox).Checked = True Then
IDs += DirectCast(CTRL, CheckBox).ID.ToString + " "
End If
End If
Next
Txt1.Text = IDs.ToString
End Sub
Ti restituisce 13 perche' è il numero di controlli che trova nella form ! (labels, checkbox, etc)
Inoltre, nel tuo codice scrivi "sValore" all'uscita dal ciclo, il che significa scrivere soltanto l'ultimo rilevato...