Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21103

New to VB6, need help..

$
0
0
Hi all,

I'm a beginner to VB6. Right now I'm doing a project to calculate an asset depreciation using Straight-Line and Double Declining method. I managed to get my coding and result right but the problem is with the output. My questions are..

a. How to show the figure in currency with only two decimal points?
b. How to fix the output arrangement in the listbox?


Attachment 96633

Here are the codes for the Straight Line Method button.
Code:

Private Sub btnStraight_Click()

    Dim description As String
    Dim yearPurchased As Integer
    Dim cost As Double
    Dim estimatedLife As Integer
    Dim amountDepr As Double
    Dim totalDepr As Double
    Dim i As Integer
   
    totalDepr = 0
   
    description = txtDesc.Text
    yearPurchased = txtYrPurchased.Text
    cost = txtCost.Text
    estimatedLife = txtLife.Text
   
    lstResult.AddItem ("  Description: " & description)
    lstResult.AddItem ("  Year of Purchase: " & yearPurchased)
    lstResult.AddItem ("  Cost: " & cost)
    lstResult.AddItem ("  Estimated Life: " & estimatedLife)
    lstResult.AddItem ("  Method of Depreciation: straight-line method")
    lstResult.AddItem ("")
    lstResult.AddItem ("                              " & "Value at  " & "            Amount Deprec  " & "          Total Depreciation")
    lstResult.AddItem ("            Year" & "        Beg of Yr" & "                    During Year" & "                  to End of Year")
 

        For i = 1 To estimatedLife
            amountDepr = cost / estimatedLife
            If i = estimatedLife Then
            amountDepr = cost
            End If
            totalDepr = totalDepr + amountDepr
            lstResult.AddItem ("            " & yearPurchased & "          " & cost & "                        " & amountDepr & "                      " & totalDepr)
            cost = cost - amountDepr
            yearPurchased = yearPurchased + 1
        Next
End Sub

Attached Images
 

Viewing all articles
Browse latest Browse all 21103

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>