John Topley's Knowledgebase

Returning A Result From A Modal Form

Friday, 30 May 2003

This Visual Basic code illustrates the use of public properties in Visual Basic 6.0 as a way of returning a result from a modal form.

Primary Form (frmPrimary):

Option Explicit

Private Sub cmdShowSecondaryForm_Click()
   frmSecondary.Show vbModal
  
   If frmSecondary.Result = True Then
      MsgBox "Yes clicked.", vbInformation
   Else
      MsgBox "No clicked.", vbInformation
   End If
End Sub

Secondary Form (frmSecondary):

Option Explicit

' Public property.
Public Result As Boolean

Private Sub cmdNo_Click()
   Result = False
   Unload frmSecondary
End Sub

Private Sub cmdYes_Click()
   Result = True
   Unload frmSecondary
End Sub

top | index | previous | next | comments ()

home | archive | kb | media | about | contact | accessibility
Copyright © 2003 - 2005 John Topley. Made with CityDesk.