ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦h­Ócheckbox ±±¨î¦P¤@­Ótextbox

[µo°Ý] ¦h­Ócheckbox ±±¨î¦P¤@­Ótextbox

¤p§Ì³Ìªñ¦]¤u§@»Ý¨D¡A¶}©l±µÄ²EXCEL VBA¡A¤~µoıEXCEL¹ê¦b¬O³Õ¤jºë²`§r!!
½u¦³¤@­Óª¬ªp¡A­Y¦P®É¦³½Æ¼Æ­Óactivex checkbox¦P®É±±¨î³æ¤@­Ótextbox¡A¥u­n¨ä¤¤¤@­Ócheckbox¦³®Ö¿ï¡Atextbox³£·|§e²{¬Û¦Pªº¤å¦r¡A¦p¤U¹Ï
excel.png
¥Ø«e§Ú¬O¥Î³Ì²Â¤èªk¡A­Ó§O°w¹ïcheckbox_click¨Æ¥ó¨Ó§e²{§Ú©Ò»Ý­nªºµ²ªG¡A
  1. Private Sub CheckBox1_Click()
  2. If CheckBox1.Value = True Then
  3. TextBox1.Value = "click!"
  4. Else: TextBox1.Value = ""
  5. End If
  6. End Sub
  7. Private Sub CheckBox2_Click()
  8. If CheckBox2.Value = True Then
  9. TextBox1.Value = "click!"
  10. Else: TextBox1.Value = ""
  11. End If
  12. End Sub
  13. Private Sub CheckBox3_Click()
  14. If CheckBox3.Value = True Then
  15. TextBox1.Value = "click!"
  16. Else: TextBox1.Value = ""
  17. End If
  18. End Sub
  19. Private Sub CheckBox4_Click()
  20. If CheckBox4.Value = True Then
  21. TextBox1.Value = "click!"
  22. Else: TextBox1.Value = ""
  23. End If
  24. End Sub
½Æ»s¥N½X
¦ýÁ`ı±o«Ü²Â¡A©Ò¥H·Q¥Î°j°éªº¤è¦¡¨ÓÅX°Ê¡A
¦ý¬O¥ÎÀô°é§Ú´N¤£ª¾¹D­n¿ï¬Æ»ò¨Æ¥ó¤F¡AWorkbook_change¤£¦æ¡AÀµ½Ð¤j®v«ü±Ð!!!

¦^´_ 1# wenxiao
  1. Option Explicit
  2. Public MyCheak() As New Class1
  3. Private Sub Auto_Open() 'Module1ªºµ{¦¡½X,Àɮ׶}±Ò®É¦Û°Ê°õ¦æªºµ{§Ç
  4.     Dim E As OLEObject, i As Integer
  5.     With Sheet1
  6.         For Each E In .OLEObjects
  7.             If E.progID = "Forms.CheckBox.1" Then
  8.                 ReDim Preserve MyCheak(0 To i)
  9.                 Set MyCheak(i).WorkCheck = E.Object
  10.                 i = i + 1
  11.             End If
  12.         Next
  13.     End With
  14. End Sub
½Æ»s¥N½X
ª«¥óÃþ§O¼Ò²Õ
  1. Option Explicit
  2. Public WithEvents WorkCheck As MSForms.CheckBox
  3. Private Sub WorkCheck_Click()
  4.     'WorkCheck ¦³¤Ä¿ï ¶Ç¦^True  ,¨S¤Ä¿ï ¶Ç¦^ Fales
  5.     WorkCheck.Parent.TextBox1 = IIf(WorkCheck, WorkCheck.Caption, "")
  6. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

GBKEE¤j±z¦n
·PÁ±zªº¨ó§U¡A¥Ø«e¤w°Ñ·Ó±zªº¥N½X§¹¦¨ªì¨B»Ý¨D¡C
¦ý²{¦b¦³¤@­Ó¤pª¬ªp¡A
­Y®Ö¿ïcheckbox1 »P checkbox2¡Atextbox·|¥X²{±ýÅã¥Üªº¦r¦ê¡A
¦ý­Y¬O¨ú®ø®Ö¿ï¨ä¤¤¤@­Ócheckbox®É¡Atextboxªº¦r¦ê¤]·|®ø¥¢¡A
¬Ý°_¨ÓÀ³¸Ó¬O¦]¬°¦^¶Ç¤Ffalseªºª¬ºA¡A¾É­P¦r¦ê¦¨§¹ªÅ¥Õ¡C
¸Ó¦p¦ó½Õ¾ã¦¨¡A¥u­n¨ä¤¤¤@­Ócheckbox¬°®Ö¿ïªºª¬ºA¡A¦r¦ê´N·|¥X²{¡A
¤£·|¦]¬°¦³¥ô¦óªºcheckbox¨ú®ø®Ö¿ïªº°Ê§@¾É­Ptextbox¬OªÅªº¡C
¦A½Ð±z¨ó§U¡A·P®¦!!

TOP

¦^´_ 3# wenxiao
  1. Option Explicit
  2. Public WithEvents WorkCheck As MSForms.CheckBox
  3. Private Sub WorkCheck_Click()
  4.     Dim Msg As Boolean, E As Object
  5.     'WorkCheck ¦³¤Ä¿ï ¶Ç¦^True  ,¨S¤Ä¿ï ¶Ç¦^ Fales
  6.     With WorkCheck.Parent
  7.         If WorkCheck Then
  8.             .TextBox1 = WorkCheck.Name
  9.         Else
  10.             For Each E In .OLEObjects
  11.                 If E.progID = "Forms.CheckBox.1" Then
  12.                     If E.Object.Value Then Msg = True: Exit For
  13.                 End If
  14.             Next
  15.             If Msg = False Then .TextBox1 = ""
  16.         End If
  17.     End With
  18. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

Thanks a lot!
It works!

TOP

        ÀR«ä¦Û¦b : ¯à¥I¥X·R¤ß´N¬OºÖ¡A¯à®ø°£·Ð´o´N¬O¼z¡C
ªð¦^¦Cªí ¤W¤@¥DÃD