2015-09-26 116 views
0

我是新來的VB,我有這種錯誤在此代碼「字符串轉換爲雙無效VB.net」字符串轉換爲double無效VB.net

a = Val(txtTotal.Text) * 0.03 
    txt1month.Text = txtTotal.Text + a 
+1

'暗淡= Cdbl(txtTotal.Text)* 0.03' 'txt1month.Text = txtTotal.Text + a.ToString()' – Magnus

回答

0

這是因爲您正在將一個雙變量的值添加到字符串中。在這種情況下鑄造沒有完成。所以使用如下:

Dim a = Val(txtTotal.Text) * 0.03 
txt1month.Text = CStr(Val(txtTotal.Text) + a) 
+0

這是一個很好的例子,爲什麼你應該使用'&'連接串而不是'+'。 –

相關問題