国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 绵竹市| 晋中市| 西乌珠穆沁旗| 门源| 清徐县| 呼图壁县| 长治市| 饶平县| 五华县| 邛崃市| 枣庄市| 盐山县| 邵武市| 剑川县| 乌兰浩特市| 揭阳市| 炉霍县| 海南省| 天等县| 长沙市| 蕉岭县| 万源市| 江孜县| 玉山县| 德兴市| 维西| 葵青区| 龙川县| 凤山县| 昌宁县| 进贤县| 大埔区| 桐庐县| 彩票| 凤翔县| 游戏| 唐海县| 旬邑县| 凤凰县| 华阴市| 荔波县|