Basic List Box question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nkp

    Basic List Box question

    ....trying to get the following result into a list box.
    Dim cost As Double
    Dim salvage As Double
    Dim life As Double
    Dim year As Double
    Dim factor As Variant
    Dim depreciation As Double
    Dim totaldepr As Double
    Dim remainingval As Double


    Private Sub Command1_Click( )
    salvage = 200
    life = 10
    cost = CDbl(Text1)
    For year = 1 To 10
    depreciation = DDB(cost, salvage, life, year)
    totaldepr = (depreciation + totaldepr)
    remainingval = (cost - totaldepr)

    Print depreciation, "for year", year, "total
    depriciation="; totaldepr,"valu e="; remainingval
    Next year
    End Sub


    thanks for any guidance.

  • Randy Birch

    #2
    Re: Basic List Box question

    .... in a listbox ...

    Private Sub Command2_Click( )

    salvage = 200
    life = 10
    cost = CDbl(Text1)
    For year = 1 To 10
    depreciation = DDB(cost, salvage, life, year)
    totaldepr = (depreciation + totaldepr)
    remainingval = (cost - totaldepr)

    List1.AddItem depreciation & vbTab & _
    year & vbTab & _
    totaldepr & vbTab & _
    remainingval

    Next year

    End Sub



    .... in a listview ...

    Private Sub Form_Load()

    With ListView1
    .ColumnHeaders. Add , , "depreciati on"
    .ColumnHeaders. Add , , "for year"
    .ColumnHeaders. Add , , "total depriciation"
    .ColumnHeaders. Add , , "Value"
    .FullRowSelect = True
    .HideSelection = False
    .LabelEdit = lvwManual
    .View = lvwReport
    End With

    End Sub


    Private Sub Command3_Click( )

    Dim itmx As ListItem

    salvage = 200
    life = 10
    cost = CDbl(Text1)
    For year = 1 To 10

    depreciation = DDB(cost, salvage, life, year)
    totaldepr = (depreciation + totaldepr)
    remainingval = (cost - totaldepr)

    Set itmx = ListView1.ListI tems.Add(, , depreciation)
    itmx.SubItems(1 ) = year
    itmx.SubItems(2 ) = totaldepr
    itmx.SubItems(3 ) = remainingval

    Next year

    End Sub

    --

    Randy Birch
    MVP Visual Basic

    Please respond only to the newsgroups so all can benefit.


    "nkp" <weatheredwall@ btinternet.com> wrote in message
    news:bou9s8$1t4 [email protected] ernet.com...
    : ...trying to get the following result into a list box.
    : Dim cost As Double
    : Dim salvage As Double
    : Dim life As Double
    : Dim year As Double
    : Dim factor As Variant
    : Dim depreciation As Double
    : Dim totaldepr As Double
    : Dim remainingval As Double
    :
    :
    : Private Sub Command1_Click( )
    : salvage = 200
    : life = 10
    : cost = CDbl(Text1)
    : For year = 1 To 10
    : depreciation = DDB(cost, salvage, life, year)
    : totaldepr = (depreciation + totaldepr)
    : remainingval = (cost - totaldepr)
    :
    : Print depreciation, "for year", year, "total
    : depriciation="; totaldepr,"valu e="; remainingval
    : Next year
    : End Sub
    :
    :
    : thanks for any guidance.
    :


    Comment

    • nkp

      #3
      Re: Basic List Box question

      Randy...you're a star.Thanks very much.
      Best wishes

      N

      Randy Birch wrote:[color=blue]
      > ... in a listbox ...
      >
      > Private Sub Command2_Click( )
      >
      > salvage = 200
      > life = 10
      > cost = CDbl(Text1)
      > For year = 1 To 10
      > depreciation = DDB(cost, salvage, life, year)
      > totaldepr = (depreciation + totaldepr)
      > remainingval = (cost - totaldepr)
      >
      > List1.AddItem depreciation & vbTab & _
      > year & vbTab & _
      > totaldepr & vbTab & _
      > remainingval
      >
      > Next year
      >
      > End Sub
      >
      >
      >
      > ... in a listview ...
      >
      > Private Sub Form_Load()
      >
      > With ListView1
      > .ColumnHeaders. Add , , "depreciati on"
      > .ColumnHeaders. Add , , "for year"
      > .ColumnHeaders. Add , , "total depriciation"
      > .ColumnHeaders. Add , , "Value"
      > .FullRowSelect = True
      > .HideSelection = False
      > .LabelEdit = lvwManual
      > .View = lvwReport
      > End With
      >
      > End Sub
      >
      >
      > Private Sub Command3_Click( )
      >
      > Dim itmx As ListItem
      >
      > salvage = 200
      > life = 10
      > cost = CDbl(Text1)
      > For year = 1 To 10
      >
      > depreciation = DDB(cost, salvage, life, year)
      > totaldepr = (depreciation + totaldepr)
      > remainingval = (cost - totaldepr)
      >
      > Set itmx = ListView1.ListI tems.Add(, , depreciation)
      > itmx.SubItems(1 ) = year
      > itmx.SubItems(2 ) = totaldepr
      > itmx.SubItems(3 ) = remainingval
      >
      > Next year
      >
      > End Sub
      >[/color]

      Comment

      Working...