用VB寫計算器

2021-08-08 23:15:15 字數 3664 閱讀 9339

我是沒什麼心思寫計算器的。。不過要參加星火杯的話這個坎還是要過一過。。。

emmmm然後發現寫個gui真是步步艱難,先用了vs發現特麼廢流量,再用qt一直蜜汁錯誤。。然後。。然後最終還是向vb低頭orz

演算法上不存在什麼問題啦。。只是不熟悉而且很多細節需要注意。。debug幾下就好。。最重要的是學到了用程式寫程式的姿勢_(:з」∠)_

乙個不能再簡單的視窗

還有一段又臭又長的**

dim t, t1 as integer

dim x, y as double

public sub com()

x = val(l1.caption)

select case t1

case is = 1: y = y + x

case is = 2: y = y - x

case is = 3: y = y * x

case is = 4: y = y / x

end select

t1 = 0

t = 0

l1.caption = "0"

end sub

private sub form_load()

x = 0

y = 0

t = 0

t1 = 1

end sub

private sub c0_click(index as integer)

if l1.caption = "0" then

l1.caption = "0"

else

l1.caption = l1.caption + "0"

end if

end sub

private sub c1_click(index as integer)

if l1.caption = "0" then

l1.caption = "1"

else

l1.caption = l1.caption + "1"

end if

end sub

private sub c10_click(index as integer)

if t = 0 then

l1.caption = l1.caption + "."

t = 1

end if

end sub

private sub c2_click(index as integer)

if l1.caption = "0" then

l1.caption = "2"

else

l1.caption = l1.caption + "2"

end if

end sub

private sub c3_click(index as integer)

if l1.caption = "0" then

l1.caption = "3"

else

l1.caption = l1.caption + "3"

end if

end sub

private sub c4_click(index as integer)

if l1.caption = "0" then

l1.caption = "4"

else

l1.caption = l1.caption + "4"

end if

end sub

private sub c5_click(index as integer)

if l1.caption = "0" then

l1.caption = "5"

else

l1.caption = l1.caption + "5"

end if

end sub

private sub c6_click(index as integer)

if l1.caption = "0" then

l1.caption = "6"

else

l1.caption = l1.caption + "6"

end if

end sub

private sub c7_click(index as integer)

if l1.caption = "0" then

l1.caption = "7"

else

l1.caption = l1.caption + "7"

end if

end sub

private sub c8_click(index as integer)

if l1.caption = "0" then

l1.caption = "8"

else

l1.caption = l1.caption + "8"

end if

end sub

private sub c9_click(index as integer)

if l1.caption = "0" then

l1.caption = "9"

else

l1.caption = l1.caption + "9"

end if

end sub

private sub z1_click(index as integer)

comt1 = 1

end sub

private sub z2_click(index as integer)

comt1 = 2

end sub

private sub z3_click(index as integer)

comt1 = 3

end sub

private sub z4_click(index as integer)

comt1 = 4

end sub

private sub z5_click(index as integer)

tmp = mid(l1.caption, len(l1.caption), 1)

if tmp = "." then

t = 0

end if

if len(l1.caption) = 1 then

l1.caption = "0"

else

l1.caption = left(l1.caption, len(l1.caption) - 1)

end if

end sub

private sub z6_click(index as integer)

l1.caption = "0"

form_load

end sub

private sub z7_click(index as integer)

if (l1.caption <> "0") then

l1.caption = "-" + l1.caption

end if

end sub

private sub z8_click(index as integer)

coml1.caption = str(y)

end sub

用vb編了個數獨計算器

平時很喜歡玩數獨遊戲,每天只要信報上有數獨遊戲,那就不看別的了,專心致志玩一路。昨天突然想自己編乙個軟體來算吧,於是就有了這篇文章和乙個vb的數獨計算器。談思想吧,思想最重要 我用了最最笨的方法,就是每個空位都從1 9挨個填,出了問題再折回來重新填。所以這樣的想法一定要用到遞迴了,就是不斷呼叫自身來...

用C 寫多型計算器

多型計算器涉及到的知識點有繼承,重寫,多型,抽象類,抽象方法 以父類做模板,子類套用 呼叫方法時,向下轉型,父類引用指向子類引用 根據計算符號來確定父類要指向的子類 設定迴圈,迴圈為字串的長度,使用length接收 將迴圈到的字元轉換為byte格式 如果byte不為數字範圍,表明包含非數字字元 如果...

用VB寫的基於合法性判斷的加法計算器

軟體說明 軟體介面 1.text1輸入第乙個加數,要求只能是數字型別,字元無效,輸入後按tab後判斷輸入值是否合法,如果不合法 輸入了除數字型別之外的其他字元,如abc 則text1自動清空,如果合法,則游標到下乙個加數的位置 2.text2輸入後,是通過按回車來判斷合法性,所以游標不會變化,按了回...