Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. Public Class Form1
  2.     Private Sub btn_run_Click(sender As System.Object, e As System.EventArgs) Handles btn_run.Click
  3.         Dim msgTxt As String = "你選的是" & vbCrLf      'vbCrLf換行
  4.         Dim ObjCB As CheckBox
  5.  
  6.         For Each tmpCB As Object In Me.Controls '將所有在Form1的控制項全部巡迴一次
  7.             If tmpCB.GetType.ToString() = "System.Windows.Forms.CheckBox" Then
  8.                 ObjCB = CType(tmpCB, CheckBox)
  9.  
  10.                 If ObjCB.Checked Then
  11.                     msgTxt = msgTxt + ObjCB.Text + vbCrLf
  12.                 End If
  13.             End If
  14.         Next
  15.         MsgBox(msgTxt)
  16.     End Sub
  17. End Class