Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2004, 07:04 PM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compile Error on Let/Get pair

Hi:

I've run into a compile error with the following propery let/get pair:

Public Property Let ShippingID(ByVal StoreOrderID As Long, ByVal ShippingMethodID As Long)

    m_utility.Visit.Orders.SetShippingID StoreOrderID, ShippingMethodID

End Property


Public Property Get ShippingID() As Long

    Call CheckLoad
    ShippingID = m_ShippingID

End Property

The Let property uses the two parameters to update a value (ShippingMethodID) for a specific record (StoreOrderID) in a table.

The Get returns the values for that record in that table (the StoreOrderID is already known internally)

The compile error is:

Definitions of property procedures are inconsistent, or a property procedure has an optional parameter, a ParamArray, or an Invalid Set final parameter


I found I can get around the problem by redefining the Get name so that it is different than the Let Property name:


Public Property Get ShippingMethodID() As Long

    Call CheckLoad
    ShippingMethodID = m_ShippingMethodID

End Property

I don't understand why it should complain about the Let/Get pair. Is it because they have a different number of parameters (Let (2), Get (0))?

Thanks,

JK
 
Old June 14th, 2004, 03:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Property Let and Property Get have to have the same parameters, save for the last parameter in the Property Let which is the return value for the Property Get. You are Letting a Store Order's Shipping Method but only Getting a Shipping Method. Think about it, you don't Let a Combo Box List Index's Item Data property but only get the Item Data, you get the List Index's Item Data.

You either need to add a StoreOrderID to your ShippingMethodID Property Get or add another Property Let/Get pair for the StoreOrderID. With the second method you would call the StoreOrderID Property Let to internally store the StoreOrderID and then call the ShippingID Let/Get properties.

Regards
Owain Williams
 
Old June 14th, 2004, 01:00 PM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Owain:

Thanks for the information. Do you know of a resource that deals specifically with this topic? I have a book on building objects with VB 6, and it mentions that the let and the get have to be the same datatype, and it also says what you said, but in a roundabout way. I'd like to get more information on the subject.

Thanks again.

JK





Similar Threads
Thread Thread Starter Forum Replies Last Post
compile error yogeshyl Excel VBA 0 December 12th, 2007 06:41 AM
Compile error: Syntax error: & Else without HELP Corey VB How-To 2 April 21st, 2006 03:25 PM
Compile Error: Michael Gavel BOOK: Beginning Access VBA 2 January 20th, 2004 11:36 AM
Compile Error aglatfel Access VBA 2 January 13th, 2004 04:01 PM
compile error burdickdave C# 1 October 20th, 2003 01:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.