OUR VIDEOS GALLERY MEMBER SPONSORSHIP VENDOR SPONSORSHIP

User Tag List

Page 51 of 51 FirstFirst ... 495051
Results 501 to 502 of 502

Thread: Fuel consumption / economy report

  1. #501
    Patrol Guru Coldcomfort's Avatar
    Join Date
    Sep 2012
    Location
    Yea, Victoria
    Posts
    603
    Thanks
    136
    Thanked 320 Times in 168 Posts
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I forgot all about this.... Here it is. Copy and past it into powershell. Powershell should be standard on W11 and W10. Use powershell ISE. Click view at the top of the app.. Click Show script Pane. Paste the script in the new white script pane. Click the green arrow at the top of the powershell app. The rest should be self explanatory.

    Simple powershell fuel usage script

    Add-Type -AssemblyName System.Windows.Forms

    # Create the form

    $form = New-Object System.Windows.Forms.Form

    $form.Text = "Fuel Consumption Calculator"

    $form.Size = New-Object System.Drawing.Size(350,220)

    $form.StartPosition = "CenterScreen"

    # Labels

    $label1 = New-Object System.Windows.Forms.Label

    $label1.Text = "Liters Used:"

    $label1.Location = New-Object System.Drawing.Point(20,20)

    $form.Controls.Add($label1)

    $label2 = New-Object System.Windows.Forms.Label

    $label2.Text = "Kilometers Driven:"

    $label2.Location = New-Object System.Drawing.Point(20,60)

    $form.Controls.Add($label2)

    $label3 = New-Object System.Windows.Forms.Label

    $label3.Text = "Liters per 100 km:"

    $label3.Location = New-Object System.Drawing.Point(20,140)

    $form.Controls.Add($label3)

    # Textboxes

    $textBoxLiters = New-Object System.Windows.Forms.TextBox

    $textBoxLiters.Location = New-Object System.Drawing.Point(150,20)

    $form.Controls.Add($textBoxLiters)

    $textBoxKms = New-Object System.Windows.Forms.TextBox

    $textBoxKms.Location = New-Object System.Drawing.Point(150,60)

    $form.Controls.Add($textBoxKms)

    $textBoxResult = New-Object System.Windows.Forms.TextBox

    $textBoxResult.Location = New-Object System.Drawing.Point(150,140)

    $textBoxResult.ReadOnly = $true

    $form.Controls.Add($textBoxResult)

    # Calculate Button

    $buttonCalc = New-Object System.Windows.Forms.Button

    $buttonCalc.Text = "Calculate"

    $buttonCalc.Location = New-Object System.Drawing.Point(50,100)

    $buttonCalc.Add_Click({

    $liters = [double]$textBoxLiters.Text

    $kms = [double]$textBoxKms.Text

    if ($kms -ne 0) {

    $result = ($liters / $kms) * 100

    $textBoxResult.Text = "{0:N2}" -f $result

    } else {

    $textBoxResult.Text = "Invalid input"

    }

    })

    $form.Controls.Add($buttonCalc)

    # Reset Button

    $buttonReset = New-Object System.Windows.Forms.Button

    $buttonReset.Text = "Reset"

    $buttonReset.Location = New-Object System.Drawing.Point(180,100)

    $buttonReset.Add_Click({

    $textBoxLiters.Text = ""

    $textBoxKms.Text = ""

    $textBoxResult.Text = ""

    })

    $form.Controls.Add($buttonReset)

    # Show the form

    $form.Topmost = $true

    $form.Add_Shown({$form.Activate()})

    [void]$form.ShowDialog()
    Be the person that your dog thinks you are!!

  2. #502
    Beginner
    Join Date
    Aug 2025
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1999 TD42t coil cab ute - 3.1t
    average 16.0-16.4L / 100km

    This is about a 50/50 mix of light traffic driving and highway driving.

Page 51 of 51 FirstFirst ... 495051

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •