Compile Error:  Expected: = (VB6)

Posted on 2003-02-22
Medium Priority
Last Modified: 2012-05-04
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
Question by:ShawnCurry
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
LVL 18

Accepted Solution

bobbit31 earned 111 total points
ID: 7999580
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)

Expert Comment

ID: 7999761
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


Author Comment

ID: 8022842
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

771 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