Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Public Event OnRunReport()
  4. Public Event OnExit()
  5.  
  6. Public Property Get InformationText() As String
  7.  
  8. InformationText = lblInfo.Caption
  9.  
  10. End Property
  11.  
  12. Public Property Let InformationText(ByVal value As String)
  13.  
  14. lblInfo.Caption = value
  15.  
  16. End Property
  17.  
  18. Public Property Get InformationCaption() As String
  19.  
  20. InformationCaption = Caption
  21.  
  22. End Property
  23.  
  24. Public Property Let InformationCaption(ByVal value As String)
  25.  
  26. Caption = value
  27.  
  28. End Property
  29.  
  30. Private Sub btnRun_Click()
  31.  
  32. RaiseEvent OnRunReport
  33.  
  34. End Sub
  35.  
  36. Private Sub btnExit_Click()
  37.  
  38. RaiseEvent OnExit
  39.  
  40. End Sub
  41.  
  42. Private Sub UserForm_QueryClose(CloseMode As Integer, Cancel As Integer)
  43.  
  44. If CloseMode = vbFormControlMenu Then
  45. Cancel = True
  46. Hide
  47. 'Even if I change the two lines above with this the error happens:
  48. 'RaiseEvent OnExit
  49. 'However, if I simply write END in stead of those two lines
  50. 'anything works quite ok...
  51. 'but that is a bit brutal.
  52.  
  53. End If
  54.  
  55. End Sub
  56.  
  57. Option Explicit
  58.  
  59. Private WithEvents objSummaryForm As frmMain
  60.  
  61. Private Sub Class_Initialize()
  62.  
  63. Set objSummaryForm = New frmMain
  64.  
  65. End Sub
  66.  
  67. Private Sub Class_Terminate()
  68.  
  69. Set objSummaryForm = Nothing
  70.  
  71. End Sub
  72.  
  73. Public Sub Show()
  74.  
  75. If Not objSummaryForm.Visible Then
  76. objSummaryForm.Show vbModeless
  77. Call ChangeLabelAndCaption("Press Run to Start", "Starting")
  78. End If
  79.  
  80. With objSummaryForm
  81. .Top = CLng((Application.Height / 2 + Application.Top) - .Height / 2)
  82. .Left = CLng((Application.Width / 2 + Application.Left) - .Width / 2)
  83. End With
  84.  
  85. End Sub
  86.  
  87. Public Sub Hide()
  88.  
  89. If objSummaryForm.Visible Then objSummaryForm.Hide
  90.  
  91. End Sub
  92.  
  93. Public Sub ChangeLabelAndCaption(strLabelInfo As String, strCaption As String)
  94.  
  95. objSummaryForm.InformationText = strLabelInfo
  96. objSummaryForm.InformationCaption = strCaption
  97. objSummaryForm.Repaint
  98.  
  99. End Sub
  100.  
  101. Private Sub objSummaryForm_OnRunReport()
  102.  
  103. MainGenerateReport
  104. Refresh
  105.  
  106. End Sub
  107.  
  108. Private Sub objSummaryForm_OnExit()
  109.  
  110. Hide
  111.  
  112. End Sub
  113.  
  114. Public Sub Refresh()
  115.  
  116. With objSummaryForm
  117. .lblInfo = "Ready"
  118. .Caption = "Task performed"
  119. End With
  120.  
  121. End Sub
  122.  
  123. Option Explicit
  124.  
  125. Private objPresenter As clsSummaryPresenter
  126.  
  127. Public Sub MainGenerateReport()
  128.  
  129. objPresenter.ChangeLabelAndCaption "Starting and running...", "Running..."
  130. GenerateNumbers
  131.  
  132. End Sub
  133.  
  134. Public Sub GenerateNumbers()
  135.  
  136. Dim lngLong As Long
  137. Dim lngLong2 As Long
  138.  
  139. tblMain.Cells.Clear
  140.  
  141. For lngLong = 1 To 4
  142. For lngLong2 = 1 To 1
  143. tblMain.Cells(lngLong, lngLong2) = lngLong * lngLong2
  144. Next lngLong2
  145. Next lngLong
  146.  
  147. End Sub
  148.  
  149. Public Sub ShowMainForm()
  150.  
  151. If (objPresenter Is Nothing) Then
  152. Set objPresenter = New clsSummaryPresenter
  153. End If
  154.  
  155. objPresenter.Show
  156.  
  157. End Sub
  158.  
  159. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  160.  
  161. Private Sub UserForm_QueryClose(CloseMode As Integer, Cancel As Integer)
  162.  
  163. Option Explicit
  164. dim mfrmMain as ufMain
  165.  
  166. Sub ShowMainForm2()
  167. If ufMain Is Nothing Then
  168. Set ufMain = New mfrmMain
  169. End If
  170. mfrmMain.Show vbModeless
  171. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement