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

熱點內容
蘋果手機游戲無法聯網 瀏覽:184
正規編程器件有哪些 瀏覽:422
carplay建議下什麼app 瀏覽:326
邢台紀委網站怎麼下載 瀏覽:881
java視頻處理開源 瀏覽:666
tcp小程序 瀏覽:512
怎麼將串口數據傳入資料庫 瀏覽:119
小程序開發需要什麼 瀏覽:423
表一對應表二數據混雜怎麼提取 瀏覽:603
cad文件轉cdr格式的文件怎麼打開嗎 瀏覽:521
初一數學復習資料哪個網站好 瀏覽:574
蘋果id在別的ipad上登陸不了 瀏覽:284
艾碼編程是什麼 瀏覽:214
g代碼特點 瀏覽:616
微信有個別字不顯示 瀏覽:695
ps打不開pdf文件嗎 瀏覽:735
ipadappleid申請流程 瀏覽:103
aspx用什麼資料庫 瀏覽:520
小米工具文件夾選項在哪裡 瀏覽:75
u盤cad圖形文件不能用 瀏覽:2

友情鏈接