dim a a=inputbox("請(qǐng)輸入一個(gè)大于100的數(shù)") a=int(a) 'inputbox返回的是字符串, 我們把他變成整數(shù) : ) if a 100 then msgbox("正確") if a 100 then msgbox("錯(cuò)誤")
還有一個(gè)更簡(jiǎn)單的
dim a a=inputbox("請(qǐng)輸入一個(gè)大于100的數(shù)") a=int(a) 'inputbox返回的是字符串, 我們把他變成整數(shù) if a 100 then msgbox("正確") else msgbox("錯(cuò)誤") end if
dim a a=inputbox("請(qǐng)輸入一個(gè)大于100的數(shù)") a=int(a) 'inputbox返回的是字符串, 我們把他變成整數(shù) if a 100 then msgbox("正確") elseif a=100 then msgbox("老大, 你耍我?") else msgbox("錯(cuò)誤") end if
Dim a,b,c,d a=inputbox("a是:","輸入半徑") b=Inputbox("b是:","輸入半徑") d=Inputbox("答案:","輸入答案") d=int(d) '在這里我們?nèi)〕隽薲的值, 變成整數(shù), 在放回"d"這個(gè)盒子里 c=a*2+b*2 if d=c then Msgbox("你好聰明") else Msgbox("你好豬頭 自己的題還不會(huì)!") end if
dim a,b a=inputbox("輸入一個(gè)數(shù) 10") b=inputbox("輸入另一個(gè)數(shù) 10") a=int(a) b=int(b) if a 10 and b 10 then msgbox("正確") else msgbox("錯(cuò)誤") end if
dim a,b a=inputbox("輸入一個(gè)數(shù) 10") b=inputbox("輸入另一個(gè)數(shù) 10") a=int(a) b=int(b) if a 10 or b 10 then msgbox("正確") else msgbox("錯(cuò)誤") end if
這段程序讓你輸入兩個(gè)值, 只要有一個(gè)大于10, 就返回成功. 其實(shí)and和or很好理解, 我讀"if a 10 or b 10 then" 這一句, 用華語(yǔ)是這樣:"如果a大于10或者b大于10, 那么...". 這樣是不是就很好理解了呢.
select case 變量名 case 值 語(yǔ)句 case 值 語(yǔ)句 case else 語(yǔ)句 end select
我們舉個(gè)例子就能很簡(jiǎn)單的說(shuō)明:
dim a a=inputbox("輸入一個(gè)1--3的值") a=int(a) '處理inputbox返回字符串的問(wèn)題 select case a case 1 msgbox("壹") case 2 msgbox("貳") case 3 msgbox("叁") case else msgbox("輸入錯(cuò)誤") end select
dim a a=inputbox("請(qǐng)輸入1--3的值") a=int(a) if a=1 then msgbox("壹") elseif a=2 then msgbox("貳") elseif a=3 then msgbox("叁") else msgbox("輸入錯(cuò)誤") end if