Why is this happening winMain.pushGenerateCode.Action, line 8 Type mismatch error. Expected Int64, but got enum CheckBox.VisualStates select case int64(checkLowerCase.VisualState)

Ok… this is weird.

I went to compile my program for windows and mac, and when I do just mac, everything builds fine.

When it gets to the windows part, I get this error:

winMain.pushGenerateCode.Action, line 8
Type mismatch error.  Expected Int64, but got enum CheckBox.VisualStates
select case int64(checkLowerCase.VisualState)

What is the difference? And how do I fix it?

I have tried with targetOS.Windows, but it is a no go.

Regards

Try doing the select case over the enum returned in CheckBox.visualState, or cast to integer which is auto converted to 32 or 64 based on architecture.

select case checkLowerCase.VisualState
case CheckBox.VisualStates.Checked

case CheckBox.VisualStates.UnChecked

case CheckBox.VisualStates.Indeterminate

end select

Hi Graham.

Ok this seems to work. So first and foremost, thank you.

Secondly, WHY does this work, but my version doesn’t?

Regards

Where you building 32bit windows version, or 64bit version? macOS is 64bit only, so all enums would be int64. Using integer is safest way as it is int32 on 32bit builds and int64 on 64bit builds.

If you can just use the enum value itself, easier to read and follow your code later.

Here it works…

Try building as 32bit

Yep. Bug… But as x86 32 bit is obsolete, it’s low impact.

Hi All.

I looked at the Build Settings for Windows, which had somehow “flipped” to 32 bit. I normally always have it as 64 bit, because as was quoted, my Mac is 64 bit. Will watch and advise.

So… if you had used CType instead of casting, your version would have worked too:

Select Case CType(checkLowerCase.VisualState, Integer)