Dim a property does not recognise a value assigned to it

I have the following snippet of code to update a data table but I get the error when I try and run it.

Type “Item” has no member named “DateEntered”
e.DateEntered = BBDateEnteredText.Text

Have I missed something fundamental or do I just need to change my med’s.

Dim e As New Item
e.ItemType = BBItemType
e.DateEntered = BBDateEnteredText.Text
e.Descriptor = BBDescriptorText.Text
e.Frequency = BBFrequencyText.Text
e.NextDue = BBNextDueText.Text
e.Amount = BBAmountText.Text
e.Weekly = BBWeeklyText.Text

If session.AddItemsRow(e.ItemType,e.DateEntered,e.Descriptor,e.Frequency,e.NextDue,e.Amount,e.Weekly) Then
  MsgBox("1 AddItemsRow Added")
Else
  MsgBox("There was an AddItemsRow error")
End If

Does your class ‘Item’ have a property called “DateEntered”?

Probably. :slight_smile:

Where is the definition of ‘item’ ?
The property is probably spelled slightly differently.
What does auto complete suggested when you get as far as e.D ?

The Text.Text is somewhat redundant and would drive me bonkers.

It also is not a good idea to call a BevelButton a SomethingText because it is not a Text, it is a BevelButton.

Thanks Guys,

I have a class called item with each of the properties in the list. That’s what’s got me confused.

I thought about the spelling, more specifically if I had somehow introduced a non-printing character so I did a cut and paste from the property in the class to make sure. Autocomplete also agrees with DateEntered as it offers me the choice.

I use the ???Text, ???Label, ???Button, etc, syntax to keep track of what I should be looking at. I don’t disagree that it can be a bit …(shall we just say - “entertaining”). I am new to Xojo so I need to pamper myself a bit at this stage.

Sorry, but I missed the point about the bevel button…

After your suggestions I decided to delete the class altogether and recreate it and it now works fine. Go figure…

Thanks for the feedback.

Trust me, it is more confusing than helpful in the long run. What if there are two or three properties you need to modify and keep track of?

Using correct syntax also helps reinforce that you are dealing with objects. You are not just dealing with the Text even though it may seem so. I know getting my head around object-oriented thinking was the hardest bit for me, and every little helps.

That exactly is my point. You are addressing the BevelButton, not a text. You want the text property of the BevelButton.

In your terminology you mix up the object (the BevelButton) with one of its properties (the .text) which will hinder developing object-oriented thinking. It will also make it harder for others (and yourself) when you have to go over the code again in 6 or 12 months time, especially when you address other properties beside .text

What about this post says anything about a BevelButton?

@Markus,

I had to go back and re-read your comment a couple of times because I really couldn’t get my head around what your were saying. But then I got thrown out of bed at 2:00 am with a very low blood sugar count (I’m a brittle diabetic) and believe it or not; while desperately sucking the life out of an orange; the penny dropped. I am “metaphorically assigning” a property to an object in the form of it’s name whereas the object has a property called text. I am philosophically thinking of it as a piece of text rather than just an object with text as one of it’s properties.

Your reference to bevel button had me thrown but I assume you are assuming this is a button action method; which it is.

Thanks for the nudge.

@Anthony: Yup, that’s it. Welcome to the next level :wink:

I wrote BevelButton because I assumed the BB stood for that.

It is also a good idea to prefix object names with the type of object, so you always know what type of object you are dealing with. So for example you have:

LB_UserList.cell( 1, 1 ) = TF_FirstName.text + TF_LastName.text

LB_UserList.cell( 1, 1 ) = popCity.text + CommaSpace + dictZipCodes.value( popCity.text )

Another advantage of using prefixes is that it makes it easy to find the control in a window code view as all the controls are sorted alphabetically by name. So the listboxes are together, the textareas, etc

@Markus,

Thanks mate. Given your comment about prefixing the object name with it’s type I understand the BevelButton(BB) reference. I can see the advantage and am changing my code to this style. It does make it easier.

Cheers.