CLASS or TYPE declaration may not be inside a control block

You tried to include a Class or Type statement inside one or another of the following block statements: Do, For, ForAll, If...Then...Else...EndIf, Select Case, While. This is not allowed. For example:

If 1 = 1 Then
   Class MyClass   ' Illegal
      ' ...
   End Class
End If

Move the Class or Type statement to outside the block.