Solved

Strange Syntax error on a VBScript Class definition

Posted on 2006-11-01
4
701 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Questions about INCLUDE FILES 2 45
CREATE DATABASE 3 44
SP inserts data with order number, then push the rest one order up 11 43
PHP $_POST vs asp request 4 56
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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