No longer cast Enums as Integers in 2016R3??

Can we no longer cast enums as Integers in 2016R3? I just installed it and code that had worked is now broken…

Or is this a bug?

I think it’s a bug. It works fine on 32 bit builds…

What’s your code? I just did a quick test and it seemed to cast to an Integer fine in a 64-bit build:

Public Enum Test Zero One End Enum

Dim enumValue As Integer = Integer(Test.One) MsgBox("Value = " + enumValue.ToText) ' displays 1

Dim i1 as Int32 = Int32(SourcePickerClass(me.RowTag(me.ListIndex)).JAPRX.VideoRotation)

VideoRotation is an Enum property of the class.

This throws a type mismatch error in 64 bit…

I just build a test project. Filing Bug report

You first need to cast the enum to Int64 as an Integer enum is a Int64 enum in a 64bit compile. Then convert it to Int32.

Aha! That does it. But the compile error does not even come close to indicating that. Wow. What a pain - you have to then have a #If statement with basically the same code for 32 bit and 64 bit builds. Or I suppose you could cast it as a 64 bit integer anyhow even for a 32 bit build…

OK - Following Paul’s example of using Integer to cast does work. The LR should be updated then as it still uses Int32…

Or just use “Integer” on all build types?

Maybe you shouldn’t chain so many function calls and casts into one statement?

That has nothing to do with anything.

Yes. That’s the better way to do it. The LR should state that… :slight_smile:

I’m pretty sure it does. :slight_smile:

My bad. It does now. :slight_smile:

What I meant by my comment was, that you would have found the error earlier yourself (while you were still thinking that it was a Xojo bug). I found the error by copying the code from your post and splitting it into each statement and cast.

Actually that had nothing to do with it. What had everything to do with it was not realizing that the enum would need to be cast to 64 bit integer in 64 bit builds. Since the LR stated Int32, my assumption was that you needed to use Int32.

Yes it did. You would have found the error earlier yourself if you hadn’t chained so many statements in one line.

No I wouldn’t have. You aren’t listening to me. The LR was incorrect. Paul fixed it.