導航:首頁 > 編程知識 > vb編程計算器怎麼用

vb編程計算器怎麼用

發布時間:2023-10-16 04:18:48

1. 如何用VB做簡易的四則運算計算器

很簡單的:窗口放入四個COMMAND控制項(Caption屬性分別為+、-、X、÷),三個TEXT控制項,再放入三個Label控制項(Caption屬性分別為:操作數1、操作數2和計算結果),窗口的Caption屬性改為「四則運算」
代碼如下:
Private Sub Command1_Click()
If Val(Text1.Text) + Val(Text2.Text) <> Int(Val(Text1.Text) + Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) + Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Command2_Click()
If Val(Text1.Text) - Val(Text2.Text) <> Int(Val(Text1.Text) - Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) - Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End If
End Sub
Private Sub Command3_Click()
If Val(Text1.Text) * Val(Text2.Text) <> Int(Val(Text1.Text) * Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) * Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
Private Sub Command4_Click()
If Val(Text1.Text) / Val(Text2.Text) <> Int(Val(Text1.Text) / Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) / Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub

2. 怎樣用vb編程一部簡單的計算器呢

1、打開VB新建一個EXE。

3. 如何用vb編寫簡單計算器

不知道你想要哪種,偶是新手,只會最簡單的
首先拖出三個text,再拖出4個Command按鈕 caption分別為+ - * / 這樣就准備就緒了
先講一下簡單用法,第一個text是第一個加數/被減數/因數/被除數,而第二個text是第二個加數/減數/因數/除數,第三個text是和/差/積/商,在text1輸入一個數,text2輸入一個,然後分別點擊command「+ - * /」text3就會出現結果
然後隨便單擊一個窗口,把裡面的文字刪去,再寫上:
Private Sub Command1_Click()
Text3.Text = Str$(Val(Text1.Text) + Val(Text2.Text))
End Sub

Private Sub Command2_Click()
Text3.Text = Str$(Val(Text1.Text) - Val(Text2.Text))
End Sub

Private Sub Command3_Click()
Text3.Text = Str$(Val(Text1.Text) * Val(Text2.Text))
End Sub

Private Sub Command4_Click()
Text3.Text = Str$(Val(Text1.Text) / Val(Text2.Text))
End Sub
然後運行,應該就可以了

閱讀全文

與vb編程計算器怎麼用相關的資料

熱點內容
wifisd的密碼 瀏覽:694
把excel表格插入word 瀏覽:117
經發e家app忘記密碼怎麼辦 瀏覽:921
goagent教程 瀏覽:344
桌面文件全選按鍵 瀏覽:105
PM2019支持哪些格式文件 瀏覽:272
全拼app現在叫什麼名字 瀏覽:476
win10現在成熟了嗎 瀏覽:727
win10mtp段落無效 瀏覽:862
cbf收銀機用什麼app 瀏覽:336
javascript變數頁面 瀏覽:766
網路相冊淘寶 瀏覽:60
編程拉絲機怎麼樣 瀏覽:897
msdn不是最新版本 瀏覽:749
參加編程比賽學什麼編程好 瀏覽:349
把c盤的桌面文件移走了怎麼辦 瀏覽:949
2025第三代軍用北斗升級版 瀏覽:925
魅藍手勢密碼怎麼弄 瀏覽:509
蘋果store怎麼充值 瀏覽:224
note4應用程序許可設置在哪裡 瀏覽:489

友情鏈接