Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2012 > Visual Basic 2012 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2012 General Discussion For any discussions about Visual Basic 2012topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2012 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 21st, 2014, 10:35 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to compute sum of years digit in vb.net

below is the code i use to calculate for the sum of years digit depreciation which start from the first month of the year to last which is okay for me. but what i want now is, let say we are already done with two (2) months remaining ten (10) month. How can i compute like the 2 examples below.

2014 $5,500 $5,000.00 28% (10/12) x (5/15) $1,389 $1,389 $4,111

2015 $4,111 $5,000.00 28% [(2/12) x (5/15)] + [(10/12) x (4/15)] $1,389 $2,778 $2,722



Dim Cost, Scrap, Life, Period, BegValue, EndValue, Deprec, AccumDeprec, YearPurch As Double
Dim Fmt As String = "###,##0.00"

Cost = txtcost.Text
Scrap = txtscrap.Text
Life = txtlife.Text
YearPurch = txtyear.Text
Period = txtlife.Text



DataGridView1.ColumnCount = 6
DataGridView1.Columns(0).Name = "Begin Year"
DataGridView1.Columns(1).Name = "Begin Value"
DataGridView1.Columns(2).Name = "Depreciation"
DataGridView1.Columns(3).Name = "Accum.Depreciation"
DataGridView1.Columns(4).Name = "End Value"
DataGridView1.Columns(5).Name = "End Year"

DataGridView1.Rows.Clear()

BegValue = Cost

For Period = 1 To Life

Deprec = SYD(Cost, Scrap, Life, Period)
AccumDeprec += Deprec
EndValue = BegValue - Deprec

Dim row As String() = New String() {YearPurch, _
FormatNumber(BegValue), _
FormatNumber(Deprec), _
FormatNumber(AccumDeprec), _
FormatNumber(EndValue), _
YearPurch}



DataGridView1.Rows.Add(row)

BegValue = EndValue


If Period = Life - 1 Then

Deprec = BegValue - Scrap

Else

Deprec = SYD(Cost, Scrap, Life, Period)

End If

YearPurch += 1

Next
Reply With Quote
  #2 (permalink)  
Old May 21st, 2014, 03:06 AM
Registered User
Points: 36, Level: 1
Points: 36, Level: 1 Points: 36, Level: 1 Points: 36, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I a sorry to come back with the same question.

2014 $5500 $5000.00 28% (10/12) x (5/15) $1389 $1389 $4111
2015 $4,111 $5,000.00 28% [(2/12) x (5/15)] + [(10/12) x (4/15)] $1,389 $2,778 $2,722

below is the code i use to calculate for the sum of years digit depreciation which start from the first month of the year to last which is okay for me. but what i want now is, let say we are already done with two (2) months remaining ten (10) month. How can i compute like the 2 examples above.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Cost, Scrap, Life, Period, BegValue, EndValue, Deprec, AccumDeprec, YearPurch As Double
HTML Code:
[html] Dim Fmt As String = "###,##0.00"
    Cost = TxtCost.Text
    Scrap = txtscrap.Text
    Life = TxtLife.Text
    YearPurch = txtYear.Text
    Period = TxtLife.Text
    DataGridView1.ColumnCount = 6
    DataGridView1.Columns(0).Name = "Begin Year"
    DataGridView1.Columns(1).Name = "Begin Value"
    DataGridView1.Columns(2).Name = "Depreciation"
    DataGridView1.Columns(3).Name = "Accum.Depreciation"
    DataGridView1.Columns(4).Name = "End Value"
    DataGridView1.Columns(5).Name = "End Year"
    DataGridView1.Rows.Clear()
    BegValue = Cost
    For Period = 1 To Life
        Deprec = SYD(Cost, Scrap, Life, Period)
        AccumDeprec += Deprec
        EndValue = BegValue - Deprec
        Dim row As String() = New String() {YearPurch, _
                                             FormatNumber(BegValue), _
                                             FormatNumber(Deprec), _
                                             FormatNumber(AccumDeprec), _
                                             FormatNumber(EndValue), _
                                             YearPurch}
        DataGridView1.Rows.Add(row)
        BegValue = EndValue
        If Period = Life - 1 Then
            Deprec = BegValue - Scrap
        Else
            Deprec = SYD(Cost, Scrap, Life, Period)
        End If
        YearPurch += 1
    Next
[/html]
Reply With Quote
  #3 (permalink)  
Old May 21st, 2014, 03:41 AM
Registered User
Points: 36, Level: 1
Points: 36, Level: 1 Points: 36, Level: 1 Points: 36, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this and find out the best answer
http://www.daniweb.com/software-deve...w-to-in-vb.net
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to compute the total in datagridview vb 2010? handsome .NET 4 and Visual Studio 2010 General Discussions 18 March 21st, 2014 12:29 PM
Sum of numbers that was insert will automatic compute and appear in total text field newphpcoder PHP Databases 0 December 23rd, 2010 01:34 AM
Difference between GROUP BY and COMPUTE BY rhd110 SQL Server 2005 1 April 28th, 2008 03:31 AM
Compute Balance zone Excel VBA 2 August 17th, 2007 09:16 AM
Compute sum(column name) statement in DTS Package praragon SQL Server DTS 1 March 27th, 2006 09:23 PM



All times are GMT -4. The time now is 05:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.