关于使用financial.ddb函数有什么建议吗?我需要只使用financial.ddb函数在标签中显示折旧计划。我能够在期末显示最后折旧的价值,但我不知道如何显示该期间内每年的价值。
例如,如果用户输入的资产成本为1,000 an,使用寿命为4年,其残值为100美元,则应显示:
第一年: 500.00
第二年: 250.00
第三年: 125.00
第4年: 25.00
但是,我的代码(下面)显示了每年25.00。
私有子Button1_Click(ByVal发送方为System.Object,ByVal e为System.EventArgs)处理ByVal 1
Dim cost As Double
Dim life As Double = CDbl(ComboBox1.SelectedItem)
Dim salvage As Double
Dim numberperiod As Integer
Dim period As Integer
Dim depreciation As Double
Dim isconverted1 As Boolean
Dim isconverted2 As Boolean
Dim isconverted3 As Boolean
isconverted1 = Double.TryParse(TextBox1.Text, cost)
isconverted2 = Double.TryParse(TextBox2.Text, salvage)
isconverted3 = Integer.TryParse(TextBox3.Text, period)
For numberperiod = 1 To period Step 1
depreciation = Financial.DDB(cost, salvage, life, period)
Label1.Text += numberperiod.ToString & " -> " & Convert.ToString(depreciation) _
& ControlChars.NewLine
Next numberperiod
End Sub非常感谢你看这个。
发布于 2011-04-10 21:54:30
我认为您只是想将数字周期传递给DDB方法而不是句点。
depreciation = Financial.DDB(cost, salvage, life, numberperiod)(循环调用该函数的时间为'4‘4次,而不是1,2,3,4次)
发布于 2016-04-19 21:38:52
这是问题的答案(我不知道什么时候发布),但你还是明白了。
Private Sub btnDisplay_Click(sender As System.Object, e As System.EventArgs) Handles btnDisplay.Click
Dim intAsset As Integer
Dim intSavage As Integer
Dim dblDep As Double
Dim intuseful As Integer
Dim strHeading As String = "Year Depreciation"
txtDep.Text = String.Empty
Integer.TryParse(txtAsset.Text, intAsset)
Integer.TryParse(txtSalvage.Text, intSavage)
Integer.TryParse(lstUseful.Text, intuseful)
txtDep.Text = txtDep.Text & ControlChars.NewLine
txtDep.Text = strHeading & ControlChars.NewLine
For Intterm = 1 To intuseful
txtDep.Text = txtDep.Text & ControlChars.NewLine & Intterm.ToString & " "
dblDep = Financial.DDB(intAsset, intSavage, intuseful, Intterm)
txtDep.Text = txtDep.Text & dblDep.ToString("c2") & " "
Next
End Subhttps://stackoverflow.com/questions/5613924
复制相似问题