1,模块加
Public xOBj As New MSForms.DataObject
2,第一个窗体
Private Sub CommandButton1_Click() If Me.TextBox1.Value = "" Then Exit Sub With xOBj .SetText Me.TextBox1.Value, 1 End With Unload Me UserForm2.Show End Sub Private Sub UserForm_Click() End Sub Private Sub UserForm_Initialize() Dim xStr As String, xp As String xp = VBA.vbCrLf xStr = xStr & "《咏柳》" & xp _ & "贺知章" & xp _ & "碧玉妆成一树高," & xp _ & "万条垂下绿丝绦。" & xp _ & "不知细叶谁裁出," & xp _ & "二月春风似剪刀。" Me.TextBox1.Value = xStr End Sub
3,第二个窗体
Private Sub UserForm_Activate() Me.Label1.Caption = xOBj.GetText(1) End Sub Private Sub UserForm_Initialize() Me.Label1.Caption = xOBj.GetText(1) End Sub
标签:Me,vba,UserForm,End,Sub,Private,窗体,xp,传值 From: https://www.cnblogs.com/Insist-Y/p/16964595.html