国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

用vb編一個(gè)計(jì)算器,需要用到數(shù)組,看看下面的代碼,歡迎來找碴!

2024-07-21 02:21:06
字體:
供稿:網(wǎng)友
這是我的代碼,請(qǐng)幫我看看哪有問題:(我是要用數(shù)組作個(gè)計(jì)算器)
option explicit
dim shu1 as double, shu2 as double '先后輸入的兩個(gè)數(shù)
dim result as double '做了運(yùn)算的結(jié)果
dim process, process0, process1, process2, process3, process4 as variant '保存數(shù)1與各個(gè)運(yùn)算符的過程
dim judge as variant '判斷按了那個(gè)運(yùn)算符

private sub command1_click(index as integer) '0-9數(shù)字鍵
text1.text = text1.text & index
text1.setfocus
end sub

private sub command1_keypress(index as integer, keyascii as integer) '阻止鍵盤輸入,不過不知為什么沒有用
keyascii = 0
end sub

private sub command2_click(index as integer) ' "."鍵
text1.text = text1.text & "."
end sub

private sub command3_click() '退格鍵
if text1.text = "" then
exit sub
end if
text1.text = left(text1.text, len(text1.text) - 1)
end sub

private sub command4_click() '清除鍵
text1.text = ""
end sub

private sub command5_click(index as integer) '做運(yùn)算,總覺得邏輯上哪有問題
shu1 = val(text1.text)
process = shu1
text1.text = ""
if judge = command5(0) then
process0 = shu1 + command(0)
elseif judge = command5(1) then
process1 = shu1 + command5(1)
elseif judge = command5(2) then
process2 = shu1 + command(2)
elseif judge = command5(3) then
process3 = shu1 + command5(3)
end if
shu2 = val(text1.text)
end sub

private sub command6_click() '等號(hào)
result = process + shu2
text1.text = result
if process0 then
result = shu1 + shu2
elseif process1 then
result = shu1 - shu2
elseif process2 then
result = shu1 * shu2
elseif process3 then
result = shu1 / shu2
end if
end sub

private sub text1_change()
if judge = false then
shu2 = val(text1.text)
end if
text1.setfocus
end sub


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 诸城市| 陵水| 师宗县| 湟源县| 河东区| 渝北区| 枞阳县| 潼关县| 庆元县| 云梦县| 四平市| 广南县| 桓仁| 苏尼特右旗| 佛坪县| 莆田市| 班玛县| 合阳县| 鹤峰县| 渑池县| 安阳市| 睢宁县| 贵州省| 姜堰市| 杭州市| 和田县| 旌德县| 泸水县| 于田县| 沧源| 永济市| 四平市| 二手房| 壤塘县| 仁怀市| 余姚市| 宜丰县| 格尔木市| 化德县| 竹溪县| 台中市|