资源描述:
《第8周上机练习vb及答案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Select语法格式:SelectCase表达式Case表达式列表1语句序列1Case表达式列表2语句序列2……Case表达式列表n-1语句序列n-1EndSelect值的形式1、常数2、连续范围1to1003、满足条件a>04、组合形式,逗号分隔-10,1to100例1:x=inputbox("输入一个整数")SelectCasexCase1,3,5,7,9Printx;"这是奇数"Case2,4,6,8,10Printx;"这是偶数"EndSelect20currencydeposit,weprescribeapassonaregularbasis,qil
2、ucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelender例2:SelectCasestringcCase"a"To"z","A"To"Z"Printstringc+"isaletter"Case"0"To"9"Printstringc+"isanumber"CaseElsePrint
3、stringc+“isonlyachar"EndSelect例3:score=inputbox("输入一个学生成绩")SelectCasescoreCaseis>90Printscore;"成绩等次为:A"Caseis>=80Printscore;"成绩等次为:B"Caseis>=70Printscore;"成绩等次为:C"CaseElsePrintscore;"成绩等次为:D"EndSelect嵌套selectcaseacaseif条件then语句elseif条件then20currencydeposit,weprescribeapassonaregular
4、basis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelender语句endifcase...if条件then语句elseif条件then语句EndifCaseElseif条件then语句elseif条件then语句Endifendselect作业:1、输入一个字符,判断它是
5、否数字(0-9),字母(a-z,A-Z)或者其他字符。(用select语句)PrivateSubCommand1_Click()DimStringcAsStringStringc=Text1SelectCaseStringc20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certifica
6、tebondsapplyformortgageloans,acceptingonlythelenderCase"a"To"z","A"To"Z"PrintStringc+"isaletter"Case"0"To"9"PrintStringc+"isanumber"CaseElsePrintStringc+"isonlyachar"EndSelectEndSub1、输入一个成绩(0-100),判断级别。85-100优秀,75-84良好,60-74中等,60以下(不含60)不及格。(用select语句)PrivateSubCommand1_Click()Dimsc
7、oreAsIntegerscore=InputBox("输入一个学生成绩")SelectCasescoreCaseIs>=85Printscore;"成绩等次为:优秀"CaseIs>=7520currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformor
8、tgageloans,acceptin