Error setting up MBS Object as property in a Module

using MAC OS

i’m getting an error with a Global property “cannot get property’s value”

see screen shot

please advise

You’ve made a computed property but didn’t put any code in the Get or Set method. Effectively it’s not readable or writable. Try a regular property instead.

when i use a regular property, then run the app i get an exception
i think because the Object is not declared from within the current method dont know really
this is an MBS class “StringToVariantOrderedMapMBS”
Screen Shot 2021-09-02 at 7.49.20 PM

You need to initialize the property. Something like

PriceTab = New StringToVariantOrderedMapMBS

You may want to do that in the Open event. Then you can use it everywhere.

Tim
PriceTab = New StringToVariantOrderedMapMBS

No Dim?

Tried that in the Open event of MainWindow, but still get the exception

please advise

No. No Dim. Dim creates a variable local to the event which does not survive once the event finishes. I presume you have a global property named PriceTab and it’s type is StringToVariantOrderedMapMBS. That property needs to be New’d before you try to use it.

1 Like

I am not using “DIM”
i have a global property named PriceTab of type StringToVariantOrderedMapMBS yes

Screen Shot 2021-09-02 at 10.45.40 PM
Screen Shot 2021-09-02 at 10.46.13 PM

Make sure you instantiate it with New before you call LoadGridHashTable.

And make sure LoadGridHashTable does not contain a Dim PriceTab.

MainWin.open

PriceTab = New StringToVariantOrderedMapMBS

LoadGridHashTable

LoadGridHashTable has no Dim for the PriceTab Object ,

Tim

I have checked and rechecked my code, i still get an exception using MACOS 10.11 / and 10.15

please advise


So this is progress. You’re no longer getting a NilObjectException. You now get a different exception. So you’ve got it instantiated successfully.

I did just notice your code

hRtn = PriceTab.Value(cellData(0)) = cellData(1)

That is almost certainly wrong. Try just

PriceTab.Value(cellData(0)) = cellData(1)
1 Like

What is hRtn defined as ??

In a line that says X = A = B ,
the variable X must be a boolean. A=B is either true or false
In your debugger, hRtn is shown as ‘nil’
A boolean cannot be nil

If you expect hRtn to become an object, you are coding as if you were using C.
That wont work here.

A ‘keynotfound’ exception is of the kind you get from using a dictionary.
So if you say x = mydictionary.value("fred’) you would get that error if there was no key of “fred”

===============

What are you actually trying to do here?

cellData = split(t.readline,"|")
creates an array of strings called cellData

cellData.sort
puts these into alphabetical order

What would StringToVariantOrderedMapMBS really add to that for you?

I am storing keys / values at the start of my app
PriceTab is a Hash table ex: PriceTab.value(Key as string) = Value as string
hRtn is Variant and is suppose to return status of the operation if i understood the MBS class correctly

all in all i am probably not using the class correctly for what i want or i am not using the right class for what i want

What i am trying to do
I want to load a series of keys and values at the start of my app.
the Object must be global or Public so all windows and methods can see it , and recall the values using the keys in later operations

Please advise

ok i removed the hRtn and no more exceptions.
i need to see if this class will do what i want, so far it the Hashtable seems to be working

thx to All