我正在使用VBA的基本編碼來創建一個模板,用於從Windows中的其他屏幕提取數據。當它拉出數字時,它們被格式化爲字符串。我現在需要將字符串轉換爲雙精度,以便添加/減去它們。我一直在嘗試一切,但似乎無法弄清楚。將VBA字符串轉換爲雙精度值
Me.salesprice = Trim(scrn.GetString(11, 65, 10))
'This would be formatted as 25,000.00
Me.salestax = Trim(scrn.GetString(12, 66, 10))
Me.pastdue = Trim(scrn.GetString(14, 65, 10))
Me.assessedppt = Trim(scrn.GetString(18, 66, 10))
Me.secdep = Trim(scrn.GetString(17, 65, 10))
assessedppt = Convert.ToDouble(Me.assessedppt)
uappt = Convert.ToDouble(Me.uappt)
salesprice = Convert.ToDouble(Me.salesprice)
salestax = Convert.ToDouble(Me.salestax)
pastdue = Convert.ToDouble(Me.pastdue)
lc = Convert.ToDouble(frmDetails.lc)
totalfinance = salesprice + salestax + pastdue - secdep + assessedppt + uappt + lc
totalsalesprice = salesprice + pastdue
ppt = assessedppt + uappt
當我這樣做,我得到以下錯誤:
Compile error: Variable not defined, and it highlights the first Convert function.
'Convert.ToDouble'是VB.NET,這是一種完全不同的語言。在VBA中,函數是'CDbl'。 – Comintern