當前位置:編程學習大全網 - 編程軟體 - VB做加減乘除的代碼是什麽?

VB做加減乘除的代碼是什麽?

代碼如下 \x0d\'已增加操作數正確性驗證及 除數不能為0驗證 \x0d\\x0d\Private Sub Command1_Click() \x0d\If IsNumeric(Text1.Text) And Text1.Text "" And IsNumeric(Text2.Text) And Text2.Text "" Then \x0d\Select Case Combo1.ListIndex \x0d\Case 0 \x0d\Text3.Text = Val(Text1.Text) + Val(Text2.Text) \x0d\Case 1 \x0d\Text3.Text = Val(Text1.Text) - Val(Text2.Text) \x0d\Case 2 \x0d\Text3.Text = Val(Text1.Text) * Val(Text2.Text) \x0d\Case 3 \x0d\If Val(Text1.Text) 0 Then \x0d\Text3.Text = Val(Text1.Text) / Val(Text2.Text) \x0d\Else \x0d\MsgBox "除數不能為0", , "錯誤" \x0d\End If \x0d\End Select \x0d\Else \x0d\MsgBox "請輸入操作數", , "錯誤" \x0d\End If \x0d\End Sub \x0d\\x0d\Private Sub Form_Load() \x0d\Combo1.AddItem "+" \x0d\Combo1.AddItem "-" \x0d\Combo1.AddItem "*" \x0d\Combo1.AddItem "/" \x0d\Combo1.ListIndex = 0 \x0d\Text1.Text = "" \x0d\Text2.Text = "" \x0d\Text3.Text = "" \x0d\Command1.Caption = "計算" \x0d\\x0d\End Sub

  • 上一篇:Android的APP客戶端和服務器端壹般是用什麽協議
  • 下一篇:DX是什麽意思
  • copyright 2024編程學習大全網