6 Replies - 293 Views - Last Post: 23 April 2019 - 11:44 PM Rate Topic: -----

#1 kart1023   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 02-April 19

Maintenance Schedule in VB

Posted 22 April 2019 - 05:00 PM

I am making a maintenance schedule in VB and want to have the user be able to input their miles and then a list of recommended services comes up afterwards. The recommendations are in 20,000 mile increments. I also saved a some of these in a text file but went another route for now.
Public Class Mileage
    Dim Mileage As Integer
    'Dim 0_5000() As String = IO.File.ReadAllLines("0_5000.txt")
    'Dim 10000() as String = Io.File.ReadAlllines("10000.txt")


    Private Sub BtnComputeMileage_Click(sender As Object, e As EventArgs) Handles BtnComputeMileage.Click
        If Mileage <= 0 Or > 20000 Then
            ListBox1.Items.Add(inspect And adjust all fluid levels,
            inspect wiper blades
            , Rotate tires
            , Inspect brake lingings/drumsand brake pads/discs
            , replace cabin air filter
            , Replace engine oil And oil filter
            , inpect ball joints And dust covers
            , inspect brake lines And hoses
            , inspect drive shaft boots
            , inspect engine coolant
            , inspect exhaust pipes And mountings
            , inpect radiator And condenser
            , inspect steering gear
            , inspect steering linkage And boots
            , inspect rear differential oil/transfercase oil)
            End If
        If Mileage <= 20000 Or > 40000 Then
            ListBox1.Items.Add(Replace cabin air filter
                                , replace engine air filter
                                , replace engine oil And oil filter
                                , inspect transmission
                                , inspect fuel lines
                                )
                                End If

        If Mileage <= 40000 Or > 60000 Then
            ListBox1.Items.Add(Replace cabin air filter
                                , preplace engine oil And oil filter
                                , replace spark plugs
                                , inspect ball joints And dust covers
                                , inspect drive shaft boots
                                , ingpect engine coolant)

            If Mileage <= 60000 Or > 80000 Then
                ListBox1.Items.Add(inspect And adjust all fluid levels
                                    , inspect wiper blades
                                    , rotate tires
                                    , inspect brake lingings/drums And brake pads/discs
                                    , inpect exhaust pipes And mountins
                                    , inspect radiator condenser
                                    , inspect steering gear
                                    , replace engine oil And oil filter)

                If Mileage <= 80000 Or > 100000 Then
                    ListBox1.Items.Add(inspect steering lingage And boots
                                        , inspect rear differential oil/transfer case oil
                                        , inspect transmission
                                        , inspect fuel lines 
                                        , inspect wiper blades
                                        , rotate tires
                                        , inspect And adjust all fluid levels
                                        , replace cabin air filter)

                    'If  > 5000 Then
                    'ListBox1.Items.Add(0_5000)

                    'End If

                    MessageBox.Show("")
    End Sub
End Class

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Maintenance Schedule in VB

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14995
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: Maintenance Schedule in VB

Posted 22 April 2019 - 08:23 PM

You neglected to ask a quesiton.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,050
  • Joined: 12-December 12

Re: Maintenance Schedule in VB

Posted 23 April 2019 - 12:04 AM

These statements

If Mileage <= 0 Or > 20000 Then


are invalid syntax and your attempt to use ListBox1.Items.Add is not correct. Check the basic usage for this Add method. (In particular, strings need to be quoted.)
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2836
  • View blog
  • Posts: 11,132
  • Joined: 03-December 12

Re: Maintenance Schedule in VB

Posted 23 April 2019 - 12:11 PM

Aside from the logic being incorrect, and I'm guessing pseudo code being used?

Is this a school assignment? That will direct what I suggest next.
Was This Post Helpful? 0
  • +
  • -

#5 kart1023   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 02-April 19

Re: Maintenance Schedule in VB

Posted 23 April 2019 - 05:13 PM

lic Class FormDepreciation
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'variable purchase year, purchase price, and depreciation
'this depreciation schedule will have to be updated as each year passes
'since its 2019 you cant find the depreciation of a brand new vehicle

Dim Year As Decimal = 2019 - CDec(txtYear.Text)
Dim purchaseprice As Decimal = CDec(txtPrice.Text)
Dim depreciation As Decimal
'here is a procedure similar to the tax problem we worked in class
' in the first year of the vehicles life it will depreciate by 25%
' after the first year the vehicle will continually depreciate byt 15.6%
Select Case Year
Case Is = 1
depreciation = CDec(purchaseprice * 0.25)
Case Else
depreciation = CDec(purchaseprice * ((1 - 0.156) ^ Year))
End Select

txttotaldep.Text = depreciation.ToString

txtcarvalue.Text = CStr(purchaseprice - depreciation)

restarted with this. but something isnt quite working right. it seems to work for when the car is twenty years old but nothing else.

yes this is for a school project

lic Class FormDepreciation
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'variable purchase year, purchase price, and depreciation
        'this depreciation schedule will have to be updated as each year passes
        'since its 2019 you cant find the depreciation of a brand new vehicle

        Dim Year As Decimal = 2019 - CDec(txtYear.Text)
        Dim purchaseprice As Decimal = CDec(txtPrice.Text)
        Dim depreciation As Decimal
        'here is a procedure similar to the tax problem we worked in class
        ' in the first year of the vehicles life it will depreciate by 25%
        ' after the first year the vehicle will continually depreciate byt 15.6%
        Select Case Year
            Case Is = 1
                depreciation = CDec(purchaseprice * 0.25)
            Case Else
                depreciation = CDec(purchaseprice * ((1 - 0.156) ^ Year))
        End Select

        txttotaldep.Text = depreciation.ToString

        txtcarvalue.Text = CStr(purchaseprice - depreciation)

restarted with this. but something isnt quite working right. it seems to work for when the car is twenty years old but nothing else.

yes this is for a school project
[/quote]
Was This Post Helpful? 0
  • +
  • -

#6 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2836
  • View blog
  • Posts: 11,132
  • Joined: 03-December 12

Re: Maintenance Schedule in VB

Posted 23 April 2019 - 05:43 PM

Please stay focused
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,050
  • Joined: 12-December 12

Re: Maintenance Schedule in VB

Posted 23 April 2019 - 11:44 PM

For your most recent code please provide details of input, output, and expected output.

You do not need to write Case Is = 1 just Case 1. However, you should not attempt such a precise comparison with a decimal number. Year is an integer value so use an integer throughout for it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1