Skip to content

Cannot coerce type 'KeyCodeConstants' to 'Long' #185

@Kr00l

Description

@Kr00l

Describe the bug
When passing a 'KeyCodeConstants' variable to an API which expects a 'Long' the error is "Cannot coerce" is produced.

To Reproduce

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Public Function KeyToggled(ByVal KeyCode As KeyCodeConstants) As Boolean
KeyToggled = CBool(LoByte(GetKeyState(KeyCode)) = 1)
End Function

Expected behavior
That the variable can be coerced to 'Long', like in VBx.

Screenshots
image

Desktop (please complete the following information):

  • OS: [e.g. Windows 10]
  • twinBASIC compiler version [e.g. 0.10.933]

Additional context
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfirmedthe issue has been verified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions