VB超简单问题,高分,在线等,急!

来源:百度知道 编辑:UC知道 时间:2024/06/04 07:38:00
任意输入一个字符串,输出其中大写字母并统计其个数。

商品购物打折:0-500元,9.5 折;500-1000,9折;1000→2000,8.5折;2000→3000,8折;3000→4000,7.5折;4000→5000,7折;5000以上(不含5000)6.5折。编程序写完,输入商品价格W,输出应付金额Y。

要代码。谢谢。

第一部分:
dim strInput as string
dim lDes as long
dim ltp as long
dim lchr(1 to 26) as long

for ltp=1 to 26
lchr(ltp)=0
next
strInput=inputbox("请输入字符串:")
for ltp=1 to len(strInput)
lDes=asc(mid(strInput,ltp,1))
if lDes>=65 and lDes<=90 then
lchr(lDes-64)=lchr(lDes-64)+1
end if
Next

strInput = ""
for ltp=1 to 26
strInput = strInput & "字母" & Chr(ltp+64) & "的个数为" & Cstr(lchr(ltp)) & vbCrlf
next
msgbox strInput

第二部分(对输入的金额按包含低价,不包含不包含高价数额分类,即高价格按高折扣计算):
private sub goods()
dim strInput as String
dim ltp as long
dim ldata as Single

strInput = trim$(inputbox("请输入字符串:"))
if strInput="" then
msgbox "请输入有效商品价格!"
exit sub
elseif not isnumeric(strinput) then
msgbox "请输入有效商品价格!"
exit sub
end if
l