'在FormB: private m_strValue as string public sub FormShow(strValue as string) m_strValue = strValue . . Me.show strValue = m_strValue end sub private sub CommondButton1_Click m_strValue = "newValue" end sub'在FormA: private sub CommandButton1_Click dim l_strValue as string call FormB.Formshow(l_strValue) msgbox l_strValue end sub
使用属性:Form2中写: dim aa as string public property get Form2Data() as string Form2Data=aa end propertyForm1中调用:dim dd as stringdd=Form2.Form2Data
有窗口中定义私有变量,然后定义公共的访问函数如: dim a as stringpublic Function GetValue () as string GetValue = a end Function不推荐直接用公共的变量传递参数!!
用窗体属性可以实现,如:Public Property Get Flag() As Boolean'取得 Flag = mFlag End Property Public Property Let Flag(vData as Boolean)'设置 mFlag=vData End Property在B窗体Unload 时传递值 frmA.Flag=True,类似于这种写法
private m_strValue as string
public sub FormShow(strValue as string)
m_strValue = strValue
.
.
Me.show
strValue = m_strValue
end sub
private sub CommondButton1_Click
m_strValue = "newValue"
end sub'在FormA:
private sub CommandButton1_Click
dim l_strValue as string
call FormB.Formshow(l_strValue)
msgbox l_strValue
end sub
dim aa as string public property get Form2Data() as string
Form2Data=aa
end propertyForm1中调用:dim dd as stringdd=Form2.Form2Data
dim a as stringpublic Function GetValue () as string
GetValue = a
end Function不推荐直接用公共的变量传递参数!!
Flag = mFlag
End Property
Public Property Let Flag(vData as Boolean)'设置
mFlag=vData
End Property在B窗体Unload 时传递值 frmA.Flag=True,类似于这种写法
如:
然后在B的UNLOAD 事件里调用