我對於Visual Basic來說真的很陌生。所以我試圖在Visual Basic中創建一個Windows窗體應用程序,它從兩個文本框中獲取兩個數字。在運行應用程序時,我試圖計算2 + 3,但得到23。怎麼了?試圖在Visual Basic中做2 + 3。改爲23而不是
Public Class CalcForm
Private Sub sumBtn_Click(sender As Object, e As EventArgs) Handles sumBtn.Click
Dim res As Integer
res = firNum.Text + secNum.Text
Convert.ToDecimal(res)
resultNum.Text = res
End Sub
End Class
您添加secnum.text這是字符串。添加:'res = convert.ToInt32(firNum.Text)+ convert.ToInt32(secNum.Text)' – Mederic
此代碼中的'Convert.ToDecimal(res)'行不做任何事。你希望它會做什麼? – Enigmativity
非常感謝,讓我試試看。 –