- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
本帖最後由 GBKEE 於 2016-4-8 13:47 編輯
回復 1# modelcrazyer
1 表單模組程式碼- Option Explicit
- Dim AA(1 To 3) As New Class1
- Private Sub CommandButton1_Click()
- Dim theTextBox As Control, K As Integer, I As Integer
- K = 10
- For I = 1 To 3
- Set theTextBox = Me.Controls.Add("Forms.TextBox.1", "TextBox" & I, True)
- Set AA(I).C_TextBox = theTextBox
- With theTextBox
- .Left = 210
- .Top = K
- K = .Top + .Height + 18
- End With
- Next I
- Set theTextBox = Nothing
- End Sub
複製代碼 2 物件類別模組新增一模組:會自動命名 Class1- Option Explicit
- Public WithEvents C_TextBox As MSForms.TextBox
- Private Sub C_TextBox_Change()
- If Not IsNumeric(C_TextBox) Then MsgBox C_TextBox & " 不是數字"
- End Sub
複製代碼 |
|