最近在學VB 想請教各位~
我寫一了一個四則運算 可是一直出問題 不知道如何解決 麻煩幫幫忙 我的問題在哪呢?
--------------------------------------------------------------------------------------------------------------------------
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
txtResult.BorderStyle = BorderStyle.None
End Sub
Private Sub btnCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCount.Click
Dim M1, M2, result As Integer
Dim txtType As String '設定運算的東西
M1 = Val(txtM1.Text) '數1
M2 = Val(txtM2.Text) '數2
txtResult.Text = "" '結果
If txtType = "+","-","*","/" Then '這個不知道怎麼寫
Else
MsgBox("請輸入 +、-、*、/")
End If
Select Case txtType
Case "+"
result = M1 + M2
Case "-"
result = M1 - M2
Case "*"
result = M1 * M2
Case "/"
If M2 = 0 Then
MsgBox("除數不得為零!", MsgBoxResult.Ok)
Else
result = M1 / M2
End If
End Select
txtResult.Text = result
End Sub
End Class
--------------------------------------------------------------------------------------------------------------------------