?
Solved

Compile Error:  Expected: = (VB6)

Posted on 2003-02-22
3
Medium Priority
?
837 Views
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.


THE PROBLEM:

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
0
Comment
Question by:ShawnCurry
[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
3 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 111 total points
ID: 7999580
how are you calling those methods? i'm assuming something like this:

setMake(x, y)
and
setModel(x,y,z)

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

setMake x, y
and
setModel x, y, z

OR

Call setMake(x,y)
and
Call setModel(x,y,z)
0
 
LVL 5

Expert Comment

by:JohnMcCann
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.

e.g.

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


0
 
LVL 3

Author Comment

by:ShawnCurry
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.
0

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