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

熱點內容
ps3文件分割視頻 瀏覽:280
微信圖片一鍵轉發軟體 瀏覽:331
如何判斷s200plc編程電纜 瀏覽:691
太原編程培訓班哪個好 瀏覽:171
樹葉吹奏教程 瀏覽:6
社交app帶來了哪些社會問題 瀏覽:394
如何安裝愛寶8800數據採集器 瀏覽:712
文件保存了怎麼找不到了 瀏覽:476
彩票網站怎麼辨真假 瀏覽:840
pr找不到該文件 瀏覽:963
java移除panel 瀏覽:354
jsp填充jsp 瀏覽:166
海關外貿大數據在哪裡查 瀏覽:381
思特奇java筆試題 瀏覽:121
葫蘆俠在手機中的文件名 瀏覽:813
plc編程應該怎麼收錢 瀏覽:584
c語言中源文件由什麼組成 瀏覽:890
linuxhttpdphp配置文件 瀏覽:607
拆單數據要怎麼保存 瀏覽:17
mac電腦怎樣壓縮文件到100m 瀏覽:645

友情鏈接