Advertisement
jsauto

Untitled

Apr 1st, 2013
7,498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.64 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement