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

[µo°Ý] ¦p¦óÅýªí³æª«¥ó¹ïÀ³¨ìª«¥óÃþ§O¤º©O¡H

[µo°Ý] ¦p¦óÅýªí³æª«¥ó¹ïÀ³¨ìª«¥óÃþ§O¤º©O¡H

¦U¦ì¤j¤j¦n¡G
p-1.rar (12.66 KB)
  ¤p§Ì¹ïª«¥óÃþ§O«ÜµÛ°g¡A
¦ý¦b¾Ç²ß¹Lµ{¤@ª½¸I¾À¡C
²{¤p§ÌºNÀÀ¤@°ÝÃD¦p¤U
¤@¡B·s¼Wªí³æ¤º§tTEXTBOX1
¤ÎCOMMANDBUTTON1
Option Explicit
Dim mycls1 As mClass1
Private Sub CommandButton1_Click()
    With mycls1
        .test2 mycls1     '¥Ñ¦¹¥i°õ¦æ¡A¦Ó§ï¥Ñ¦b MCLASS1ªºMCMD1_CLASS·|¥X²{ERROR
    End With
End Sub

Private Sub UserForm_Initialize()   
    Set mycls1 = New mClass1
    With mycls1
        Set .Txt1 = Me.Controls("TextBox1")
        Set .Cmd1 = Me.Controls("CommandButton1")
        .mTxt1 = "test"
    End With
End Sub

¤G¡B·s¼W¤G­Óª«¥óÃþ§O

--- MCLASS1 ---

Option Explicit

Public myCls2 As mClass2
Public WithEvents mTxt1 As MSForms.TextBox
Public WithEvents mCmd1 As MSForms.CommandButton

Public Property Set Txt1(setTxt1 As MSForms.TextBox)
    Set mTxt1 = setTxt1
End Property
Public Property Set Cmd1(setCmd1 As MSForms.CommandButton)
    Set mCmd1 = setCmd1
End Property

Private Sub Class_Initialize()
    Set myCls2 = New mClass2
End Sub
Private Sub mCmd1_Click()   
    'myCls2.mTest mycls1
    test2 mClass1     '¤GºØ¤è¦¡·|¥X²{°õ¦æ¶¥¬q¿ù»~'424' ¦¹³B¶·­nª«¥ó
   
End Sub
Function test2(ByVal mycls1 As mClass1)
    myCls2.mTest mycls1
End Function

--- MCLASS2  ---

Option Explicit

Sub mTest(ByVal mycls1 As mClass1)
    Dim mStr As String   
    With mycls1
        mStr = .mTxt1
    End With
End Sub

½Ð°ÝÀ³¦p¦ó­×§ï¦bMCLASS1ªºMCMD1_CLICK¼W³]MCLS1ª«¥ó©O¡H
·P®¦¦U¦ì¤j¤j¡I

¦^´_ 1# dechiuan999
ª«¥óÃþ§O¤¤¡A­n°Ñ¦Ò¨ì¦Û¤v¥»¨­³o­Óª«¥ó­n¥ÎMe
©Ò¥H§AÀ³¸Ó­n§ï¬° test2 Me

´N¹³§A¦bUserFormªºµ{¦¡½X¤¤¡A§A­nª¾¹DUserFormªºname¥i¥H¥ÎMe.Name£¸¼Ë·N«ä
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 2# stillfish00


    ·P®¦¤j¤j¡I
¤SÅý¤p§Ì¸ó¥X¤@¤j¨B¡C

´N·P®¦¡C

TOP

¦^´_ 3# dechiuan999
ªí³æ¼Ò²Õ¤¤¥iª½±µ«ü©w³oªí³æ±±¨î¶µª«¥ó
  1. Private Sub UserForm_Initialize()   
  2.     Set mycls1 = New mClass1
  3.     With mycls1
  4.         Set .Txt1 = TextBox1
  5.         Set .Cmd1 =CommandButton1
  6.      '   Set .Txt1 = Me.Controls("TextBox1")
  7.       '  Set .Cmd1 = Me.Controls("CommandButton1")
  8.         .mTxt1 = "test"
  9.     End With
  10. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¨Ã«D¦³¿ú¾{¬O§Ö¼Ö¡A°Ý¤ßµL·\¤ß³Ì¦w¡C
ªð¦^¦Cªí ¤W¤@¥DÃD