This may help to find problems when using Classes or Collections of classes. It's an application that creates a function that outputs to the Immediate Window all of a classes' variable values. (Yeah, that was long-winded but it is what it is.)

Here’s how it works. From the class you already created, copy & paste the class header into the Input textbox. The app's output textbox will display a function. Click Copy to Clipboard, and then paste it at the bottom of your class.

It's commented to death. I want new programmers to understand it. The code contains instructions and sample input/output

Here's what you need to make it work:

1) A new project

2 Two textboxes on the default form:
Set attributes to:
(name) txtInput
Font Courier New
Font Size 10
MultiLine True
scroll 3-Both
Text ""

(name) txtOuput
Font Courier New
Font Size 10
Locked True
MultiLine True
scroll 3-Both
Text ""

3) Two buttons :

(name) cmdClearTextBoxes
Text Clear Textboxes

(name) cmdCopyToClipboard
Text Copy To Clipboard


4) This Code:

VB Code:
  1. Option Explicit
  2.  
  3. Private Sub txtInput_Change()
  4.     ' paste all class header variable declarations in Input textbox
  5.     ' copy text in Output textboxes to bottom of class
  6.     ' call function when you need to know
  7.  
  8. '   Example: paste to Input textbox
  9. '
  10. '   'local variable(s) to hold property value(s)
  11. '   Private mvarLineContent As String 'local copy
  12. '   'local variable(s) to hold property value(s)
  13. '   Private mvarEntryDate As String 'local copy
  14. '   'local variable(s) to hold property value(s)
  15. '   Private mvarEntryTime As String 'local copy
  16. '
  17. '   Ouptut textbox will contain:
  18. '
  19. '   Public Function ShowAll()
  20. '     ' For debugging. shows values of all variables in class instance
  21. '     ' SYNTAX: in class instance: [instanceName].ShowAll
  22. '     ' SYNTAX: in collection of class instance: [collectionName].([index])ShowAll
  23. '     '
  24. '     ' Author: Robert Budzynowski
  25. '
  26. '       Debug.Print "LineContent = {" & mvarLineContent & "}"
  27. '       Debug.Print "EntryDate = {" & mvarEntryDate & "}"
  28. '       Debug.Print "EntryTime = {" & mvarEntryTime & "}"
  29. '
  30. '   End Function
  31.  
  32.     Dim lines() As String
  33.     Dim x As Integer
  34.     Dim mvarLoc As Integer
  35.     Dim SpaceLoc As Integer
  36.     Dim classVarName As String
  37.     Dim varName As String
  38.     Dim trimmedLine As String
  39.     Dim processInput As Boolean
  40.    
  41.     ' no point if no class header data
  42.     mvarLoc = InStr(UCase(txtInput.Text), "MVAR")
  43.    
  44.     If mvarLoc = 0 Then
  45.         MsgBox "Text entered does not contain class header data", vbOKOnly, "Input Error"
  46.        
  47.         ' clear existing output text
  48.         txtOuput.Text = ""
  49.        
  50.         ' highlight text
  51.         txtInput.SelStart = 0
  52.         txtInput.SelLength = Len(txtInput.Text)
  53.         txtInput.SetFocus
  54.     End If
  55.      
  56.     ' function header & description
  57.     txtOuput = "Public Function ShowAll()" & vbCrLf
  58.     txtOuput = txtOuput & "  ' For debugging. shows values of all variables in class instance" & vbCrLf
  59.     txtOuput = txtOuput & "  ' SYNTAX: in class instance: [instanceName].ShowAll" & vbCrLf
  60.     txtOuput = txtOuput & "  ' SYNTAX: in collection of class instance: [collectionName].([index])ShowAll" & vbCrLf
  61.    
  62.     ' please give credit where credit is due!
  63.     txtOuput = txtOuput & "  ' " & vbCrLf
  64.     txtOuput = txtOuput & "  ' Author: Robert Budzynowski" & vbCrLf
  65.     txtOuput = txtOuput & vbCrLf
  66.  
  67.     ' create array element for each line in input textbox
  68.     lines = Split(txtOuput.Text, vbCrLf)
  69.    
  70.     ' process each line of input textbox
  71.     For x = 0 To UBound(lines)
  72.    
  73.         ' check for "mvar" text is line, if so we work with it
  74.         mvarLoc = InStr(UCase(lines(x)), "MVAR")
  75.        
  76.         If mvarLoc > 0 Then
  77.             ' valid line. Trim everything prior to start of var name (usually "Private ")
  78.             trimmedLine = Right(lines(x), Len(lines(x)) - mvarLoc + 1)
  79.            
  80.             ' find the space after the var name
  81.             SpaceLoc = InStr(trimmedLine, " ")
  82.          
  83.             ' the modular var name is before the space
  84.             classVarName = Trim(Left(trimmedLine, SpaceLoc))
  85.            
  86.             ' get the var name without the mvar prefix
  87.             varName = Right(classVarName, Len(classVarName) - Len("mvar"))
  88.                        
  89.             ' this is the line you want
  90.             txtOuput = txtOuput & vbTab & "Debug.Print " & Chr(34) & varName & " = {" & Chr(34) & " & " & classVarName & " & " & Chr(34) & "}" & Chr(34) & " " & vbCrLf
  91.            
  92.         End If
  93.  
  94.     Next x
  95.    
  96.     ' finish function text
  97.     txtOuput = txtOuput & vbCrLf
  98.     txtOuput = txtOuput & "End Function"
  99.  
  100. End Sub
  101.  
  102. Private Sub cmdClearTextBoxes_Click()
  103. ' clear textboxes
  104.     txtInput.Text = ""
  105.     txtOuput.Text = ""
  106. End Sub
  107.  
  108. Private Sub cmdCopyToClipboard_Click()
  109. ' copy output text
  110.   Clipboard.Clear
  111.   Clipboard.SetText txtOuput.Text
  112. End Sub
  113.  
  114. End Sub