[VB6]Select Case - multiple expressions or ranges in each Case

  1. Dim Number
  2. Number = 8 ' Initialize variable.
  3. Select Case Number ' Evaluate Number.
  4. Case 1 To 5 ' Number between 1 and 5, inclusive.
  5. Debug.Print "Between 1 and 5"
  6. ' The following is the only Case clause that evaluates to True.
  7. Case 6, 7, 8 ' Number between 6 and 8.
  8. Debug.Print "Between 6 and 8"
  9. Case 9 To 10 ' Number is 9 or 10.
  10. Debug.Print "Greater than 8"
  11. Case Else ' Other values.
  12. Debug.Print "Not between 1 and 10"
  13. End Select


Ref
https://docs.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/select-case-statement

留言

這個網誌中的熱門文章

[VB6]使用File Dialog選擇檔案

[VB6]MSFlexGrid使用記錄

[VBA]如何藉由使用 Excel 中的 Visual Basic 程序選取儲存格/範圍