Why use a module at all? I would switch it to a shared class instead but either way there is no reason to have the instance of form3 to be created at that scope. You can have the compile function create the instance and solve the problem.
VB Code:
  1. Module Compile
  2.  
  3.  
  4. Public Function Compile(ByVal Code As RichTextBox
  5.  
  6. [b]Dim Errorfrm As New Form3[/b] 'inside the method call
  7. ' SHOW THE ERROR FORM INCASE THERE IS AN ERROR
  8. Errorfrm.Show() ' THE SECOND TIME I RUN THIS FUNCTION THIS IS WHERE I GET THE ERROR. THE FIRST TIME EVERYTHING RUNS FINE
  9.  
  10. ' CHECK TO SEE IF THERE ARE ANY LINES IN THE CODE
  11. ' IF NOT REPORT A MAJOR ERROR AND EXIT
  12. If (Code_Length = 0) Then
  13. ' ADD THE ERROR TO THE LIST
  14. Errorfrm.Errorlst.Items.Add("Line 0 - Error Code 1 - Major error, no code to be compiled")
  15. ' SINCE IT IS A MAJOR ERROR, NOTHING TO COMPILE
  16. ' EXIT THE FUNCTION AND RETURN CONTROL BACK TO THE CALLING FUNCTION
  17. Exit Function
  18. End If
  19.  
  20. End Function
  21. End Module