最近在學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

--------------------------------------------------------------------------------------------------------------------------
文章關鍵字
手邊沒有 VB.NET
所以用 VB 6 修改了程式碼
應該是不會造成困擾

個人習慣有排版的Code,所以就懶的再打一次了,直接抓圖來貼

請問他顯示說 txtType已在指派值之前使用 這是什麼意思呢?
文章分享
評分
評分
複製連結

今日熱門文章 網友點擊推薦!