Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unable to link to class module

Posted on 2002-06-18
3
Medium Priority
?
195 Views
Last Modified: 2010-05-02
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
Comment
Question by:program_viewer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 7091885
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
 

Expert Comment

by:fdcjat
ID: 7092304
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
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 180 total points
ID: 7092349
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question