本帖最后由 pcl_test 于 2016-9-3 13:32 编辑
教程裡的例題:輸入0-100的分數並根據0-20、20-40、40-60、60-80、80-100顯示a、b、c、d、e的等級,我用if 可以寫得出來,
教程又說明用select case會更加簡潔,可惜沒有範例解答,我是初學還寫不出來,希望有人能指導一下,幫我建立正確的觀念,謝謝!- option explicit
- dim a
- a = inputbox ("輸入分數0-100:")
- if a>=0 and a<=20 then
- msgbox "e等"
- elseif a>=21 and a<=40 then
- msgbox "d等"
- elseif a>=41 and a<=60 then
- msgbox "c等"
- elseif a>=61 and a<=80 then
- msgbox "b等"
- elseif a>=81 and a<=100 then
- msgbox "a等"
- else
- msgbox "輸入錯誤"
- end if
复制代码
|