導航:首頁 > 編程知識 > 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編程計算器怎麼用相關的資料

熱點內容
ug編程刀路怎麼復制不用滑鼠選取 瀏覽:97
excel文件打開擴展名錯誤 瀏覽:10
阿里巴巴怎麼做數據包 瀏覽:442
無線網路連接一直顯示未連接 瀏覽:25
windows7如何自動激活工具下載 瀏覽:57
天語救磚工具 瀏覽:839
網路體育課程有哪些 瀏覽:19
蘋果微信怎麼查看文件 瀏覽:165
安卓nba2k14面補替換 瀏覽:450
路由器密碼定時換 瀏覽:626
aicc恢復文件在哪裡 瀏覽:167
怎麼查無線網路屬性 瀏覽:874
只狼的聲音文件放在哪裡 瀏覽:219
lol盒子修復在哪個文件夾 瀏覽:308
表格里的公章怎麼導入到pdf文件上 瀏覽:844
怎樣刪除u盤不能刪除的文件 瀏覽:712
軟體編程崗位怎麼找 瀏覽:120
數字編程工程師是什麼專業 瀏覽:489
ios開發文件管理 瀏覽:877
文件名如何轉化到excel表內 瀏覽:63

友情鏈接