Solved

Strange Syntax error on a VBScript Class definition

Posted on 2006-11-01
4
722 Views
Last Modified: 2012-06-21
I am having problems with a class definition in VBScript. I am getting a syntax error for no apparent reason. This is the code that gives the error:

Class FastString
      
      Dim stringArray,growthRate,numItems
      
      Private Sub Class_Initialize()
            growthRate = 50: numItems = 0
            ReDim stringArray(growthRate)
      End Sub
      
      Public Sub Append(ByVal strValue)
            ' Next line will prevent type mismatch errors if item is null. Performance hit is negligible
            strValue=strValue & ""
            If numItems > UBound(stringArray) Then       ReDim Preserve stringArray(UBound(stringArray) + growthRate)
            stringArray(numItems) = strValue:numItems = numItems + 1
      End Sub
      
      Public Sub Reset
            Erase stringArray
               Class_Initialize
         End Sub
      
      Public Function concat()
            Redim Preserve stringArray(numItems)
            concat = Join(stringArray, "")
      End Function
      
End Class

As I said I don't see what is wrong with this. However I get a Syntax Error from this the "Class FastString" line. Now this is code that has been used before without such an error, so I'm baffled. Please Help
0
Comment
Question by:thedwalker
[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
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Preece
ID: 17850692
Do you need () after:

Public Sub Reset

Preece
0
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17850699
The code is fine. Make sure that this code is not put in incorrect place like in between a if...end if block or function... end function or another class.... end class.
0
 
LVL 1

Author Comment

by:thedwalker
ID: 17850745
Would it matter if this is included in a file that is in an if...end if statement?
0
 
LVL 58

Expert Comment

by:amit_g
ID: 17850942
Yes. You can't do that. The include files are included before any line is executed. So before any line is executed you end up having a class definition in between in...end if which is incorrect.

Why do you need a class definition inside a if logic? The code that creates the class object and calls method in it should be in the if block not the class itself.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 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