Imports System
Module PercentageChangeExample
Function PercentageChange(oldValue As Double, newValue As Double) As Double
If oldValue = 0.0 Then
Throw New ArgumentException("oldValue cannot be zero")
End If
Return ((newValue - oldValue) / oldValue) * 100.0
End Function
Sub Main()
Dim oldValue As Double = 45.0
Dim newValue As Double = 57.0
Try
Dim change As Double = PercentageChange(oldValue, newValue)
Console.WriteLine($"Percentage change: {change:F2}%")
Catch ex As Exception
Console.WriteLine("Error: " & ex.Message)
End Try
End Sub
End Module
' run:
'
' Percentage change: 26.67%
'