Skip to main content

A simple Visual COBOL 5.0 (VS 2017) Windows Forms program ... which has a datetimepicker control ... (which has a tag property) ... if you try to reference and test the tag value with  something like this:

if dateTimePicker1::Tag = "1"
    invoke type MessageBox::Show("dateTimePicker1::Tag = 1")
else
    invoke type MessageBox::Show("dateTimePicker1::Tag NOT = 1")
end-if.

... you get a compilation error "COBCH0888:  Illegal comparison for this type".

This compiles cleanly with Visual COBOL 2.2 (VS 2013).

Please advise.

Thanks.

A simple Visual COBOL 5.0 (VS 2017) Windows Forms program ... which has a datetimepicker control ... (which has a tag property) ... if you try to reference and test the tag value with  something like this:

if dateTimePicker1::Tag = "1"
    invoke type MessageBox::Show("dateTimePicker1::Tag = 1")
else
    invoke type MessageBox::Show("dateTimePicker1::Tag NOT = 1")
end-if.

... you get a compilation error "COBCH0888:  Illegal comparison for this type".

This compiles cleanly with Visual COBOL 2.2 (VS 2013).

Please advise.

Thanks.

Hi Austin1,

The Tag property is defined as an object so the comparison to a string literal is not valid and the compiler error in 5.0 is correct. To do the comparison you need to change the condition to 

if dateTimePicker1::Tag as string = "1"

I hope that helps,

Gael