返回列表 上一主題 發帖

[發問] checkbox&optionbutton值問題

本帖最後由 stillfish00 於 2014-12-16 11:14 編輯

回復 1# ayubbs
1.
  1. Private Sub CommandButton1_Click()
  2.   Dim s As String, i As Long
  3.   For i = 1 To 4
  4.     With Controls("CheckBox" & i)
  5.       If .Value Then
  6.         s = IIf(s = "", .Caption, s & ";" & .Caption)
  7.       End If
  8.     End With
  9.   Next
  10.   TextBox1.Value = s
  11. End Sub

  12. Private Sub CommandButton2_Click()
  13.   TextBox1.Value = ""
  14. End Sub
複製代碼
2.
  1. Private Sub OptionButton1_Click()
  2.   TextBox2 = OptionButton1.Caption
  3. End Sub
  4. Private Sub OptionButton2_Click()
  5.   TextBox2 = OptionButton2.Caption
  6. End Sub
  7. Private Sub OptionButton3_Click()
  8.   TextBox2 = OptionButton3.Caption
  9. End Sub
複製代碼
3.
  1. Private Sub CommandButton3_Click()
  2.   Dim i As Long
  3.   For i = 4 To 6
  4.     With Controls("OptionButton" & i)
  5.       If .Value Then
  6.         TextBox3.Value = .Caption
  7.         Exit For
  8.       End If
  9.     End With
  10.   Next
  11. End Sub
  12. Private Sub CommandButton4_Click()
  13.   TextBox3.Value = ""
  14. End Sub
複製代碼
4.
  1. Private Sub CheckBox5_Click()
  2.   UpdateTextBox4
  3. End Sub
  4. Private Sub CheckBox6_Click()
  5.   UpdateTextBox4
  6. End Sub
  7. Private Sub CheckBox7_Click()
  8.   UpdateTextBox4
  9. End Sub
  10. Private Sub CheckBox8_Click()
  11.   UpdateTextBox4
  12. End Sub

  13. Private Sub UpdateTextBox4()
  14.   Dim s As String, i As Long
  15.   For i = 5 To 8
  16.     With Controls("CheckBox" & i)
  17.       If .Value Then
  18.         s = IIf(s = "", .Caption, s & ";" & .Caption)
  19.       End If
  20.     End With
  21.   Next
  22.   TextBox4.Value = s
  23. End Sub
複製代碼
P.S.  
點選checkbox有個屬性叫GroupName
ABC 應該設置同一個GroupName
大中小 設置另一個GroupName
表達不清、題意不明確、沒附檔案格式、沒有討論問題的態度~~~~~~以上愛莫能助。

TOP

回復 5# ayubbs
見附檔,還有是Label不是Lable
lable.zip (15.79 KB) la
表達不清、題意不明確、沒附檔案格式、沒有討論問題的態度~~~~~~以上愛莫能助。

TOP

        靜思自在 : 要比誰更受誰.不要比誰更怕誰。
返回列表 上一主題