vb6 0製作科學計算器

時間 2021-10-14 23:39:19

1樓:匿名使用者

這是我很久以前編的了 你看下吧

先宣告:完全白痴的程式設計

private sub command1_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

'上面作用是為了在運算完一個算式,資料都存在的情況下,點任意一個數字鍵(包括小數點),都會自動清除顯示屏的值和下面算式的值

'如果沒有判斷的話,就會出現算完再點一個數字,數字從顯示屏最末尾出現的尷尬現象(就等於在輸入資料)

text1 = text1 + "7"

end sub

private sub command10_click()

dim tuige, tuige1

tuige = val(text1)

tuige1 = tuige mod 10

tuige = tuige - tuige1

tuige = tuige / 10

text1 = tuige

end sub

private sub command11_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "1"

end sub

private sub command12_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "2"

end sub

private sub command13_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "3"

end sub

private sub command14_click()

dim fanhui

if text1 <> "" then

fanhui = text1

label1 = fanhui

else

label1 = label1

end if

label2 = "-"

label3 = ""

label4 = ""

label5 = ""

text1 = ""

end sub

private sub command15_click()

dim pingfang

pingfang = val(text1)

if pingfang < 0 then

pingfang = 0 - pingfang

end if

pingfang = sqr(pingfang)

text1 = pingfang

end sub

private sub command16_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "0"

end sub

private sub command17_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

if text1 = "" then

text1 = "0."

else

text1 = text1 + "."

end if

end sub

private sub command18_click()

text1 = 0 - text1

end sub

private sub command19_click()

dim fanhui

if text1 <> "" then

fanhui = text1

label1 = fanhui

else

label1 = label1

end if

label2 = "+"

label3 = ""

label4 = ""

label5 = ""

text1 = ""

end sub

private sub command2_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "8"

end sub

private sub command20_click()

if label2 = "+" then

label3 = text1

label4 = "="

text1 = val(label1) + val(text1)

label5 = text1

end if

if label2 = "-" then

label3 = text1

label4 = "="

text1 = val(label1) - val(text1)

label5 = text1

end if

if label2 = "*" then

label3 = text1

label4 = "="

text1 = val(label1) * val(text1)

label5 = text1

end if

if label2 = "÷" then

if val(text1) = 0 then

text1 = "e"

else

label3 = text1

label4 = "="

text1 = val(label1) / val(text1)

label5 = text1

end if

end if

end sub

private sub command3_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "9"

end sub

private sub command4_click()

dim fanhui

if text1 <> "" then

fanhui = text1

label1 = fanhui

else

label1 = label1

end if

label2 = "÷"

label3 = ""

label4 = ""

label5 = ""

text1 = ""

end sub

private sub command5_click()

text1 = ""

label1 = ""

label2 = ""

label3 = ""

label4 = ""

label5 = ""

end sub

private sub command6_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "4"

end sub

private sub command7_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "5"

end sub

private sub command8_click()

if label5 <> "" and label5 = text1 then

text1 = ""

label1 = "": label2 = "": label3 = "": label4 = "": label5 = ""

end if

text1 = text1 + "6"

end sub

private sub command9_click()

dim fanhui

if text1 <> "" then

fanhui = text1

label1 = fanhui

else

label1 = label1

end if

label2 = "*"

label3 = ""

label4 = ""

label5 = ""

text1 = ""

end sub

private sub label1_click()

end sub

private sub label6_click()

shunzi = msgbox("你好,**測試版,bug一堆!", 1, "提示^_^")

end sub

private sub label7_click()

shunzis = msgbox("1,小數退格錯誤。2,小數點不該連按", 1, "已知bug彙總")

end sub

計算器有哪些主要的功能,科學計算器的各個鍵的功能都是些什麼呀

王啦啦啦 基本運算 負數計算 分數計算 倒數 階乘 統計計算 複數計算。計算器一般由運算器 控制器 儲存器 鍵盤 顯示器 電源和一些可選外圍裝置及電子配件,通過人工或機器裝置組成。低檔計算器的運算器 控制器由數字邏輯電路實現簡單的序列運算,其隨機儲存器只有 一 二個單元,供累加儲存用。高檔計算器由微...

kenko科學計算器如何計算開多次方

1 第一步要開啟計算器,找到 shift 按鍵然後按下。2 緊接著在計算器上找到x 3的圖示,在其上方有開n次方的轉換圖示。3 最後按下自己需要計算的具體數值,輸入後按下 即可得到n次方的最終結果。擴充套件資料 kenko科學計算器ms mr mc m m 功能1 ms 存當前顯示的數值。2 mr ...

科學函式計算器 不是電腦上的)怎麼關機

以前那些計算器按off鍵關機,現在的先按一下shift鍵,然後按ac鍵關機。一般的學生計算器按ac shift ac就可以關機 科學型計算器是電子計算器的一種,可進行乘方 開方 指數 對數 三角函式 統計等方面的運算,又稱函式計算器。科學計算器支援顯示24位數字,支援運算優先選擇模式 進位制轉換功能...