国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Visual Basic > 正文

vb簡(jiǎn)易計(jì)算器源碼

2020-01-31 16:31:32
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
代碼如下:
復(fù)制代碼 代碼如下:

/**
*Author:烏鳥(niǎo)heart
*Version:1.0
*/
Dim IntX As Double '全局變量,用于存儲(chǔ)計(jì)算的數(shù)值
Dim IntOperation As Double '標(biāo)記運(yùn)算類(lèi)型
Dim isBegin As Boolean '標(biāo)記是否已經(jīng)給IntX賦值
Public Sub Clear() '清空命令函數(shù)

screen.Caption = ""
End Sub
Public Sub SavaToIntX()

Select Case IntOperation

Case 1 '加法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX + Val(screen.Caption)
End If

Case 2 '減法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX - Val(screen.Caption)
End If

Case 3 '乘法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX * Val(screen.Caption)
'screen.Caption = IntX
End If

Case 4 '除法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX / Val(screen.Caption)
End If

End Select

End Sub

Private Sub Command0_Click()
screen.Caption = screen.Caption & 0
End Sub
Private Sub Command1_Click()
screen.Caption = screen.Caption & 1
End Sub
Private Sub Command2_Click()
screen.Caption = screen.Caption & 2
End Sub
Private Sub Command3_Click()
screen.Caption = screen.Caption & 3
End Sub
Private Sub Command4_Click()
screen.Caption = screen.Caption & 4
End Sub
Private Sub Command5_Click()
screen.Caption = screen.Caption & 5
End Sub
Private Sub Command6_Click()
screen.Caption = screen.Caption & 6
End Sub
Private Sub Command7_Click()
screen.Caption = screen.Caption & 7
End Sub
Private Sub Command8_Click()
screen.Caption = screen.Caption & 8
End Sub
Private Sub Command9_Click()
screen.Caption = screen.Caption & 9
End Sub

Private Sub CommandClear_Click() '清空命令
isBegin = False
IntOperation = 0
IntX = 0
screen.Caption = ""
End Sub

Private Sub CommandEqual_Click() '等號(hào)運(yùn)算

If IntOperation <> 0 Then '有運(yùn)算標(biāo)記的情況
Call SavaToIntX
IntOperation = 0
isBegin = False
screen.Caption = IntX
End If

End Sub

Private Sub CommandMinus_Click() '減法運(yùn)算

If IntOperation <> 0 Then '有運(yùn)算標(biāo)記的情況
Call SavaToIntX
IntOperation = 2
Call Clear

Else
IntOperation = 2
Call SavaToIntX
Call Clear

End If
End Sub

Private Sub CommandMultiple_Click() '乘法運(yùn)算
If IntOperation <> 0 Then '有運(yùn)算標(biāo)記的情況
Call SavaToIntX
IntOperation = 3
Call Clear

Else
IntOperation = 3
Call SavaToIntX
Call Clear

End If

End Sub

Private Sub CommandPlus_Click() '加法運(yùn)算

If IntOperation <> 0 Then '有運(yùn)算標(biāo)記的情況
Call SavaToIntX
IntOperation = 1
Call Clear

Else
IntOperation = 1
Call SavaToIntX
Call Clear

End If

End Sub

Private Sub CommandSlash_Click() '除法運(yùn)算

If IntOperation <> 0 Then '有運(yùn)算標(biāo)記的情況
Call SavaToIntX
IntOperation = 4
Call Clear

Else
IntOperation = 4
Call SavaToIntX
Call Clear

End If
End Sub
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 崇明县| 上饶市| 抚远县| 洱源县| 合肥市| 佛教| 荥阳市| 垣曲县| 贡山| 黄陵县| 山丹县| 察隅县| 平定县| 福贡县| 县级市| 五莲县| 大连市| 类乌齐县| 水富县| 临洮县| 奈曼旗| 凉山| 鹰潭市| 玉树县| 盐城市| 鹿邑县| 昂仁县| 鄯善县| 图片| 台湾省| 班玛县| 雅安市| 孝昌县| 莱州市| 木兰县| 衡水市| 崇州市| 正阳县| 清镇市| 北票市| 铁岭县|