Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 841
  • Last Modified:

Compile Error: Expected: = (VB6)

I have a class module - MyDataFileObject - a simple custom database class that works with sequential access files, and holds the data for my project (a simple Car purchasing wizard for my programming class).

Nearly all the data stored in this class is used in every form in my project; instead of using copy and paste, I decided to design a class module (beyond the scope of my Intro to Programming text).

So, I'm encapsulating this data (6 arrays).  The arrays are Dim'ed inside the module, and I use public methods to access the data contained.

Public Function getMake(nMake As Integer) As String

    getMake = astrMakes(nMake)
End Function

Public Function getModel(nMake As Integer, _
                         nModel As Integer) As String
    getModel = astrModels(nMake, nModel)
End Function
-Both of these work great.


Public Sub setMake(ByVal nMake As Integer, _
                   ByVal strMake As String)
    astrMakes(nMake) = strMake
End Sub

Public Sub setModel(ByVal nMake As Integer, _
                    ByVal nModel As Integer, _
                    ByVal strModel As String)
    astrModels(nMake, nModel) = strModel
End Sub

-When I create a New DataFileObject and attempt to access these methods, it gives me a "Compile Error: Expected: = "; which makes precious little sense.

For 37 points (Half of what I got) :  Can someone please tell me exactly which flaming loop VB expects me to do a reverse back flip through to accomplish this.  Thanks. Gaping bullet hole -> *;p
1 Solution
how are you calling those methods? i'm assuming something like this:

setMake(x, y)

they are subs not functions so you have to call like:

setMake x, y
setModel x, y, z


Call setMake(x,y)
Call setModel(x,y,z)
I think bobbit31  is correct.

But one thing you may wish to consider if you are using methods to get and set a value they should probably be propertys.


Public Property Get Make(ByVal nMake As Integer) As String
    Make = astrMakes(nMake)
End Property

Public Property Let Make(ByVal nMake As Integer, _
                  ByVal strMake As String)
   astrMakes(nMake) = strMake
End Property

ShawnCurryAuthor Commented:
Geez.  Heh nice of em to give ya such a descriptive error message.  Something like "Syntax Error" might have been less mystifying. Oh well.  Ima try to give ya both the points.

I had thought about doing the property let / gets, but so much stuff already works with my original arrays, and I wasnt sure if they're just methods or if they were the actual data.

I got around it..Heh.  Made em functions and used bogus return values. LMAO.  Oh well its fixed now thanks.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now