I have several class modules in my book. One of the public functions of the Class 1 module is based on data from the function of the Class 2 module, this happens four times. If the object is not in class 2, the program will fail (as expected). I find it difficult to debug the code correctly, because it seems that I can only exit the program from the main routine. I would prefer to kill the program from the Class function, but I do not know if this is possible (we can crush it here if that is the case). I am currently using On Error statements in the main routine, but they are not executed in a timely manner because a class 1 function receives data from class 2 four times.
Class 1 module function
Function oload(ByVal pload As Double, ByVal cord As cCordCol, ByVal grid As cGridCol)
' cord is a scripting.dictionary of Class Module Objects (cCord)
' grid is a scripting.dictionary of Class Module Objects (cGrid)
n1 = grid.Item(pg1).toGlobal(cord)
n2 = grid.Item(pg2).toGlobal(cord)
n3 = grid.Item(pg3).toGlobal(cord)
n4 = grid.Item(pg4).toGlobal(cord)
' do something here
oload = sum_Ploads
End Function
Above n1 thru n4 is where I call the public function of a class 2 module.
2
Function toGlobal(ByVal cord As cCordCol)
On Error Resume Next
ctype = cord.Item(Me.cord1).sys
' Missing Coordinate System Error
If Err.Number <> 0 Then
i = MsgBox("The definition of Coordinate " & Me.cord1 & " was missing from the Bulk Data " & Chr(10) & _
"File. Include this Coord in the .bdf and re-execute the program.", vbOKOnly, "Runtime Error")
' *** TERMINATE MAIN SUBROUTING HERE ***
End If
, , (me.cord1) - scripting.dictionary. .
( ) :
Sub main()
' lookup Element ID, Calc OLOAD, Sum Load Set OLOAD
On Error GoTo PROC_ERR
If dict_quad.Exists(EID) Then dict_oload.Item(LS).add_to_oload (dict_quad.Item(EID).oload(pload, dict_cord, dict_grid))
If dict_tria.Exists(EID) Then dict_oload.Item(LS).add_to_oload (dict_tria.Item(EID).oload(pload, dict_cord, dict_grid))
PROC_ERR:
If Err.Number <> 0 Then Exit Sub
End Sub
. , "goto" , "oload" . "oload" "toGlobal" .
"toGlobal"?