Hi,
I have an indexed checkbox that returns an error code:
if Window1.CB_Thumbdail.Value = true then
//try too CB_Thumbdail(index).Value
This method is protected. It can only be called from its class
Type “Int32” has no member named “Value”

Thanks
if CB_Thumbdail( index ).Value = true then
Will work and is the correct way of accessing the item.
You can only access the properties of the control outside of the window if the control is Public. The coloured box around the control names would suggest that it isn’t (although I don’t recognise the colour).
You also have to be careful of using a window instance and not a window class name in your reference. Assuming the window is called Window1 you should not try and access it as:
if Window1.CH_Thumbdail( 0 ).Value then
as Window1 is the name of the window class, not a reference to a specific instance of that window.
For example:
Var MyWind as New Window1
MyWind.ShowModal
if MyWind.CB_Thumbdail( 0 ).Value then
is good and:
Var MyWind as New Window1
MyWind.ShowModal
if Window1.CB_Thumbdail( 0 ).Value then
is not.
1 Like
CB_Thumbdail is a control set, and as such, does not have a value property.
(Which is what the error message is telling you)
The error that you get with CB_Thumbdail(index).Value is more useful.
If you are asking for that value in the ValueChanged event , then you would be looking for ‘Me’
if me.value = true then
msgbox "Item " + cstr(index) + " is now true"
else
msgbox "Item " + cstr(index) + " is now false"
end if
If you are checking the values when the window closes, then it would be something like this:
dim bWantsColor as boolean = cb_thumbdail(0).value
dim bWantsItalic as boolean = cb_thumbdail(1).value
If you want to access these values from another window, then it would be
dim bWantsColor as boolean = SomeWindowName.cb_thumbdail(0).value
dim bWantsItalic as boolean = SomeWindowName.cb_thumbdail(1).value
//assuming these controls are PUBLIC
if the controls are not public, then the window could set global variables in the ValueChanged event, or could set the value of member variables on the window, and allow other windows to access the values using access methods
Obviously if you are using API2 (I dont) , then it will be Var and index.tostring
Hi @Jeff_Tullin You do not want SomeWindowName in your references. You want SomeWindowInstance. As I said accessing by the classname is not a good idea. You could have 5 different windows all of class Window1. You want a specific window.
Thanks Ian.
I know that.
Perhaps for the benefit of clarity I should have said SomeWindowInstanceName.
Implicit instance as an aide for VB coders has much to answer for.
For the benefit of the OP:
If you add a new window to your project, it may get called Window1
Never use Window1.something in your code
Create a window object of that Window type.
Call it Banana if you like
Dim Banana as new Window1 //( I want a window that looks like this)
Then use Banana.cb_thumbdail(0).value