Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - daro

Pages: [1]
1
QB64 Discussion / Error with Constant comparison in SELECT CASE?
« on: May 17, 2021, 08:51:48 am »
I'm finding this strange error when using a constant inside of a select case, any ideas why?
I've tried many different ways but it seems to be the use of a CONST inside of the SELECT CASE giving the error.

Expected string expression on line 12
Caused by (or after) CASE "A", 1 , "a",1 , KEY_ARROW_LEFT


Code: QB64: [Select]
  1. Const KEY_ARROW_LEFT = Chr$(0) + Chr$(72)
  2. Const KEY_ARROW_UP = Chr$(0) + Chr$(72)
  3. Const KEY_ARROW_RIGHT = Chr$(0) + Chr$(77)
  4. Const KEY_ARROW_DOWN = Chr$(0) + Chr$(80)
  5. Const KEY_PAGE_UP = Chr$(0) + Chr$(73)
  6. Const KEY_PAGE_DOWN = Chr$(0) + Chr$(81)
  7.  
  8.  
  9.     keyp$ = InKey$
  10.     Select Case keyp$
  11.         Case "A", "a", KEY_ARROW_LEFT
  12.             Print " Left ";
  13.         Case "W", "w", KEY_ARROW_UP
  14.             Print " Up   ";
  15.         Case "D", "d" , KEY_ARROW_RIGHT
  16.             Print " Right";
  17.         Case "S", "s", KEY_ARROW_DOWN
  18.             Print " Down ";
  19.         Case "Z", "z", KEY_PAGE_DOWN
  20.             Print " P.Up ";
  21.         Case "X","x", KEY_PAGE_UP
  22.             Print "P.Down ";
  23.         Case KEY_ESCAPE
  24.             Exit Do
  25.     End Select
  26.  

Pages: [1]