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

熱點內容
蘋果手機密碼6位變4位 瀏覽:651
編程如何讓人物踢球 瀏覽:884
win10防藍光軟體下載 瀏覽:983
qq群文件容量 瀏覽:164
有什麼網站驗證pr 瀏覽:186
如何拍攝飄浮照片教程 瀏覽:366
劍靈白青版本刺客 瀏覽:965
卡車在哪個app可以接單 瀏覽:526
怎麼讀編程文檔java 瀏覽:501
基礎資料庫和半導體哪個好 瀏覽:118
word顯示隱藏標記 瀏覽:63
win10f4麥克風設置 瀏覽:426
昆明碼高少兒編程在哪裡 瀏覽:508
雲資料庫哪個牌子好 瀏覽:479
掃描文件多高解析度 瀏覽:487
蘋果手機js指得是什麼 瀏覽:225
編程適合什麼筆記本 瀏覽:783
c讀文本到資料庫 瀏覽:981
2010word文字背景顏色怎麼去掉 瀏覽:515
網路安全情況核查台賬是什麼 瀏覽:590

友情鏈接