用VB寫計算器
我是沒什麼心思寫計算器的。。不過要參加星火盃的話這個坎還是要過一過。。。
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)
com
t1 = 1
End Sub
Private Sub z2_Click(Index As Integer)
com
t1 = 2
End Sub
Private Sub z3_Click(Index As Integer)
com
t1 = 3
End Sub
Private Sub z4_Click(Index As Integer)
com
t1 = 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)
com
l1.Caption = Str(y)
End Sub
相關文章
- 用C語言編寫的公式計算器C語言公式
- 用VB設計VCD播放器 (轉)播放器
- VB計算器專案演算法結構分析演算法
- Java語言編寫計算器(簡單的計算器)Java
- 如何寫一個計算器?
- VB計算圓周率的方法
- 純 HTML+CSS+JavaScript 編寫的計算器應用HTMLCSSJavaScript
- 用VB編寫抽獎程式 (轉)
- 使用vue寫的計算器demoVue
- xyz計算機等級考試系統(二級c) vb編寫計算機
- 用VB編寫標準CGI程式 (轉)
- 如何編寫計算機模擬器計算機
- 用VB寫高效的影像處理程式 (轉)
- 用 150 行 Python 程式碼寫的量子計算模擬器Python
- JavaScript編寫計算器的發展史JavaScript
- 大數計算器的VB程式碼,其實肯去發掘,VB能幹很多東西。 (15千字)
- 用VB編寫COM+應用時碰到問題? (轉)
- 用VB編寫網路尋呼機(1) (轉)
- 用VB編寫網路尋呼機(2) (轉)
- Python編寫一個簡單計算器Python
- Flutter最佳入門方式——寫一個計算器Flutter
- C++簡易計算器自寫棧版C++
- win10計算器怎麼用_win10如何開啟計算器Win10
- 棧的應用——計算器的四則運算
- 用Python開發實用程式 – 計算器Python
- 簡單計算器(棧的應用)
- Electron 實戰桌面計算器應用
- 用VB編寫一個彈出選單類 (轉)
- 用VB編寫OPC客戶端訪問WINCC (轉)客戶端
- 計算器
- 用VB計算PI精確數值到30000位的程式程式碼。 (轉)
- 我們來動手編寫計算機模擬器計算機
- 自己的IE——用VB製作瀏覽器 (轉)瀏覽器
- Java 計算器Java
- 日期計算器
- 健康計算器
- VB讀寫ini檔案 (轉)
- 四則運算計算器