Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public Event OnRunReport()
- Public Event OnExit()
- Public Property Get InformationText() As String
- InformationText = lblInfo.Caption
- End Property
- Public Property Let InformationText(ByVal value As String)
- lblInfo.Caption = value
- End Property
- Public Property Get InformationCaption() As String
- InformationCaption = Caption
- End Property
- Public Property Let InformationCaption(ByVal value As String)
- Caption = value
- End Property
- Private Sub btnRun_Click()
- RaiseEvent OnRunReport
- End Sub
- Private Sub btnExit_Click()
- RaiseEvent OnExit
- End Sub
- Private Sub UserForm_QueryClose(CloseMode As Integer, Cancel As Integer)
- If CloseMode = vbFormControlMenu Then
- Cancel = True
- Hide
- 'Even if I change the two lines above with this the error happens:
- 'RaiseEvent OnExit
- 'However, if I simply write END in stead of those two lines
- 'anything works quite ok...
- 'but that is a bit brutal.
- End If
- End Sub
- Option Explicit
- Private WithEvents objSummaryForm As frmMain
- Private Sub Class_Initialize()
- Set objSummaryForm = New frmMain
- End Sub
- Private Sub Class_Terminate()
- Set objSummaryForm = Nothing
- End Sub
- Public Sub Show()
- If Not objSummaryForm.Visible Then
- objSummaryForm.Show vbModeless
- Call ChangeLabelAndCaption("Press Run to Start", "Starting")
- End If
- With objSummaryForm
- .Top = CLng((Application.Height / 2 + Application.Top) - .Height / 2)
- .Left = CLng((Application.Width / 2 + Application.Left) - .Width / 2)
- End With
- End Sub
- Public Sub Hide()
- If objSummaryForm.Visible Then objSummaryForm.Hide
- End Sub
- Public Sub ChangeLabelAndCaption(strLabelInfo As String, strCaption As String)
- objSummaryForm.InformationText = strLabelInfo
- objSummaryForm.InformationCaption = strCaption
- objSummaryForm.Repaint
- End Sub
- Private Sub objSummaryForm_OnRunReport()
- MainGenerateReport
- Refresh
- End Sub
- Private Sub objSummaryForm_OnExit()
- Hide
- End Sub
- Public Sub Refresh()
- With objSummaryForm
- .lblInfo = "Ready"
- .Caption = "Task performed"
- End With
- End Sub
- Option Explicit
- Private objPresenter As clsSummaryPresenter
- Public Sub MainGenerateReport()
- objPresenter.ChangeLabelAndCaption "Starting and running...", "Running..."
- GenerateNumbers
- End Sub
- Public Sub GenerateNumbers()
- Dim lngLong As Long
- Dim lngLong2 As Long
- tblMain.Cells.Clear
- For lngLong = 1 To 4
- For lngLong2 = 1 To 1
- tblMain.Cells(lngLong, lngLong2) = lngLong * lngLong2
- Next lngLong2
- Next lngLong
- End Sub
- Public Sub ShowMainForm()
- If (objPresenter Is Nothing) Then
- Set objPresenter = New clsSummaryPresenter
- End If
- objPresenter.Show
- End Sub
- Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
- Private Sub UserForm_QueryClose(CloseMode As Integer, Cancel As Integer)
- Option Explicit
- dim mfrmMain as ufMain
- Sub ShowMainForm2()
- If ufMain Is Nothing Then
- Set ufMain = New mfrmMain
- End If
- mfrmMain.Show vbModeless
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement