分享

【例题】选择

 夜的影子 2018-01-31
  1. dim as integer x = 5
  2. dim as integer y = -1
  3.  
  4. '' 顺序检查(简化了IF语句)
  5. select case x
  6. case 1
  7. print "it's 1"
  8. case 2, 3, 4
  9. print "it's one of 2, 3 or 4"
  10. case is >= 5
  11. print "it's >= 5"
  12. case y
  13. print "same as y"
  14. case else
  15. print "something else"
  16. end select
  17.  
  18. '' 使用跳转表(如果有大量的检查这样速度会更快,但只能用来检查常量):
  19. select case as const x
  20. case 1
  21. print "it's 1"
  22. case 2, 3, 4
  23. print "it's one of 2, 3 or 4"
  24. case 5
  25. print "it's 5"
  26. case else
  27. print "something else"
  28. end select

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约