Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Unable to link to class module

I'm currently writing a program that has module and several class modules. However I found that the main form coding unable to go to the appropriate section of the coding in one of the class module. The following is the main form coding where the reference is.

Sub new_archive()
        dlgNewArchive.Show 1, Me
    If dlgAccept Then
       comp.NewArchive rel.comfile, rel.comfold, rel.inc_file, rel.inc_subfold
       listview
    End If
End Sub


Here is the coding should be executed or referred:

Public Function NewArchive(CompFile As String, Rootfolder As String, IncludeFiles As Boolean, IncludeSubfolders As Boolean) As Long
    On Error Resume Next
    Screen.MousePointer = vbArrowHourglass
    Clear
    SetStatus csBusy
    xCompFileNew = CompFile
    xRootFolder = Rootfolder
    xExist = False
    If IncludeFiles Then
        ScanTree xRootFolder, IncludeSubfolders        
    End If
    xListView.SmallIcons = xIml      
    NewArchive = nFiles              
    Screen.MousePointer = vbNormal
    SetStatus csOK
End Function

When I perform step into of the debugging, as the debugger checks dlgAccept If statement, the line "comp.NewArchive rel.comfile, rel.comfold, rel.inc_file, rel.inc_subfold" is checked and then ignore with exiting the if statement. Is there any coding problem occurred here?

I hope to receive any comments ASAP.

Program_Viewer

0
program_viewer
Asked:
program_viewer
1 Solution
 
corvanderlindenCommented:
Suggestion :

Sub new_archive()

On error goto errh

   dlgNewArchive.Show 1, Me
   If dlgAccept Then
      comp.NewArchive rel.comfile, rel.comfold, rel.inc_file, rel.inc_subfold
      listview
   End If

exit sub

errh:
 MsgBox err.description
end sub
0
 
fdcjatCommented:
Always use "On Error Goto ..." in every Sub or Function.

Vital error information may be lost due to VB's error handling schema.

So:

Public Function NewArchive(CompFile As String, Rootfolder As String, IncludeFiles As Boolean, IncludeSubfolders
As Boolean) As Long
   'On Error Resume Next
   On error goto errh
   Screen.MousePointer = vbArrowHourglass
   Clear
   SetStatus csBusy
   xCompFileNew = CompFile
   xRootFolder = Rootfolder
   xExist = False
   If IncludeFiles Then
       ScanTree xRootFolder, IncludeSubfolders        
   End If
   xListView.SmallIcons = xIml      
   NewArchive = nFiles              
   Screen.MousePointer = vbNormal
   SetStatus csOK

exit function

errh:
MsgBox err.number & ": " & err.description
' Or any other error handling !

End Function
0
 
Arthur_WoodCommented:
have you created an instance of your class (i assume that your instance is Dimmed as :

Dim comp as MyClass
set comp = New MyClass

?

Have you included Option Explicit at the top of the Declaration section on Each form.  I ask these rather basic questions, because I do not see the direct evidence of either being the case, from the code that you have shown.

Arthur Wood
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now