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

[¤À¨É] ª«¥óÃþ§OÀ³¥Îªº¼Ò«¬

[¤À¨É] ª«¥óÃþ§OÀ³¥Îªº¼Ò«¬

¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-3-22 08:10 ½s¿è

Calculater.rar (10.34 KB) ³o¬O³Ì°ò¦ªºª«¥óÃþ§OÀ³¥Îªº¼Ò«¬
¥i±q½d¨Ò¤¤¾Ç²ß¦p¦ó«Å§iª«¥óÃþ§O
±N¦PÃþª«¥ó¶°¦X°µ¦P¤@¨Æ¥ó
¥H²³æ­pºâ¾¹¬°¨Ò

USERFORM1¼Ò²Õ
  1. Private Sub CommandButton19_Click() '=¸¹«ö¶s
  2. Dim Nr As Variant
  3. Nr = Application.Evaluate(Label1.Caption)
  4. Nr = IIf(IsError(Nr), Err.Number, Nr)
  5. If Label1.Caption <> "" Then Label2.Caption = CStr(Nr)
  6. End Sub

  7. Private Sub CommandButton20_Click() '¡ö¸¹«ö¶s
  8. If Label1.Caption <> "" Then Label1.Caption = Mid(Label1.Caption, 1, Len(Label1.Caption) - 1) '´î¤Ö¥kÃä1­Ó¤å¦r
  9. End Sub

  10. Private Sub CommandButton21_Click()
  11. Unload Me '¨ø°£ªí³æ
  12. End Sub


  13. Private Sub UserForm_Initialize() 'ªí³æªì©l¨Æ¥ó
  14. For i = 1 To 18 '±N«e­Ó«ö¶s¥[¤J°}¦C
  15.    Set ctrl = Controls("CommandButton" & i)
  16.    ReDim Preserve obj(i)
  17.    Set obj(i).MyButton = ctrl
  18. Next
  19. End Sub
½Æ»s¥N½X
Module1¼Ò²Õ
  1. Public obj() As New Class1 '°}¦CÅܼƤº®e¬O·sªºª«¥óÃþ§O
½Æ»s¥N½X
ª«¥óÃþ§O¼Ò²Õ CLASS1
  1. Public WithEvents MyButton As MSForms.CommandButton '¦¹Ãþ§Oª«¥ó¬°ªí³æ«ö¶s
  2. Sub MyButton_Click() '¦¹Ãþ§O³æÀ»¨Æ¥ó
  3. Dim MyStr As String
  4. MyStr = UserForm1.Label1.Caption '¦r¦êÅܼƪº­È¬Oªí³æ¼ÐÅÒ¤å¦r
  5. MyStr = MyStr & MyButton.Caption '¼W¥[¦r¦êÅܼƤº®e
  6. UserForm1.Label1.Caption = MyStr '±Nªí³æ¼ÐÅÒ¤å¦rÅܧó
  7. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

Public WithEvents MyButton As MSForms.CommandButton¡K­ì¨Ó¬O³o¼Ë¨Ï¥Î¡A³o¼Ë¥i¥H´î¤Ö«Ü¦hªº³]©w¡A·PÁª©¥Dªº¤À¨É
clio

TOP

        ÀR«ä¦Û¦b : ¥¬¬I¦p¼½ºØ¡A¥HÅw³ß¤ß´þ¼íºØ¤l¡A¤~·|µoªÞ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD