用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
相關文章
- 使用vue寫的計算器demoVue
- 用 150 行 Python 程式碼寫的量子計算模擬器Python
- Python編寫一個簡單計算器Python
- JavaScript編寫計算器的發展史JavaScript
- 用Python開發實用程式 – 計算器Python
- Flutter最佳入門方式——寫一個計算器Flutter
- C++簡易計算器自寫棧版C++
- win10計算器怎麼用_win10如何開啟計算器Win10
- 簡單計算器(棧的應用)
- 計算器
- 四則運算計算器
- 用java實現一個簡單的計算器Java
- c#計算器C#
- AUTOCAD——快速計算器
- Managed C++: Another VB, or VB.NET, or WhateverC++
- 物件導向的例項應用:圖形計算器物件
- 簡單計算器 (關於棧的一種應用)
- 簡單混合運算的計算器
- python簡易計算器Python
- javafx開發計算器Java
- leetcode 224 基本計算器LeetCode
- 逆波蘭計算器
- Calca for mac(文字編輯器/符號計算器) v1.5.1啟用版Mac符號
- 請寫一個整數計算器,支援加減乘三種運算和括號。Python版本Python
- 用JS點選事件做一個簡單的計算器JS事件
- Electron入門Demo之桌面應用計算器筆記(二)筆記
- 用 Tk 寫個密碼器密碼
- win10計算器在哪開啟_win10如何調出計算器Win10
- 【UniApp】-uni-app-專案計算功能(蘋果計算器)APP蘋果
- 計算機儲存器的容量計算和地址轉換計算機
- [20191010]bash行計算器.txt
- 神奇的周幾計算器
- LeetCode-224. 基本計算器LeetCode
- TimeDateCalculator for mac 時間計算器Mac
- AYBO for Mac(多功能計算器)Mac
- 寫個方法近似計算指定陣列或物件佔用記憶體的大小陣列物件記憶體
- GitHub - h33p/ofps: 用Rust編寫的計算機視覺專案GithubRust計算機視覺
- Soulver 3 for Mac(Mac計算器軟體) v3.4.15啟用版Mac
- 用python和計算機對話(計算機的語句)Python計算機