调用一个窗体后怎样返回一个值?

来源:百度知道 编辑:UC知道 时间:2024/05/25 04:47:04
rt
可不可以不用全局变量,就像"浏览文件夹的函数"SHBrowseForFolder一样,用的时候弹出一个对话框,结束后直接返回一个字符串

'form2上有一个按钮数组:
Option Explicit

Dim m_blnFeedback As Boolean

Public Function MessageBox() As Boolean
Me.Show 1
MessageBox = m_blnFeedback
Unload Me
End Function

Private Sub Command1_Click(Index As Integer)
m_blnFeedback = (Index = 0)
Me.Hide
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Me.Visible Then
Cancel = True
End If
End Sub

'form1上的调用
Private Sub Command1_Click()
Dim frm As Form2

Set frm = New Form2
MsgBox frm.MessageBox
Set frm = Nothing
End Sub

添加一个标准模块(.bas),然后在里边定义全