?
Solved

Strange Syntax error on a VBScript Class definition

Posted on 2006-11-01
4
Medium Priority
?
748 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 2000 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

762 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