Python Forum
Can Python be my replacement for VBScript?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can Python be my replacement for VBScript?
#1
I read yesterday that Microsoft is going to discontinue VBScript in future releases of Windows which will eventually create a few problems for me so I'm wondering if Python can become my replacement scripting language. The bottom line is that I'm retired and would only be using (learning) any alternative language to replace a couple of small applications so I'm not really interested in spending a lot of time learning a new language that I would seldom use once my applications are converted. Here's a brief description of both of my apps:

1. A VBScript that I can invoke from my desktop that opens a log file. parses though that log file looking for a particular string. Once that string of data is found, the date/time within that string is compared to the current date/time and a message box is displayed showing how many days have elapsed since application that generated the log file successfully ran.

2. An .HTA application that has contains VBScript code. The Hypertext code created a small GUI that allows input of two dollar amounts and upon pressing the GO button the script calculates the amount of principal and interest has been applied to a home mortgage account and displays those two values in the GUI.

So, my question to those of you that know Python, is whether Python can be setup to replace my VBScript program and can Python be be embedded within an .HTA program replacing the VBScript that's currently in place? If Python is not suitable as a language for both of my applications is there a language better suited for my needs?
Reply
#2
python is a computer language. As thus, you can program it to do whatever you want.
I don't know what type of restrictions microsoft plans to put on the language, which could limit what you can do, but expect that you will be able to do at minimum what you could do with VBScript.
Reply
#3
(Oct-12-2023, 05:53 PM)Moondoggy Wrote: 2. An .HTA application that has contains VBScript code. The Hypertext code created a small GUI that allows input of two dollar amounts and upon pressing the GO button the script calculates the amount of principal and interest has been applied to a home mortgage account and displays those two values in the GUI.
This should answer here it,here i write the app with Python Flask and Tailwind .
So a way to do modern web-development,and still keep it simple as this can look like VBScript💀(RIP) code.
Pick simple stuff like used here,can also mention htmx🔥(my clear favorite).

Not that there anything wrong with React,Vue,Svelte can add that to eg Flask to if needed,but many start there an add extra complicity unnecessary.
Web-development is messy place 😵,but can pick stuff that make it simpler.

The look.
[Image: JAQE6b.png]

All code.
mortage.py
from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def mortgage_calculator():
    principal = 0
    interest_paid = 0
    error_message = ""
    if request.method == 'POST':
        try:
            principal = float(request.form['principal'])
            interest_rate = float(request.form['interest_rate']) / 100
            years = float(request.form['years'])
            months = years * 12
        except ValueError:
            error_message = "Please enter valid numerical values."
            return render_template('index.html', error_message=error_message)
        if principal <= 0 or interest_rate <= 0 or years <= 0:
            error_message = "Please enter positive values for principal, interest rate, and years."
            return render_template('index.html', error_message=error_message)
        monthly_interest_rate = interest_rate / 12
        monthly_payment = principal * (monthly_interest_rate * (
            1 + monthly_interest_rate)**months) / ((1 + monthly_interest_rate)**months - 1)
        total_payment = monthly_payment * months
        interest_paid = total_payment - principal
        return render_template('mortage.html', principal=principal, interest_paid=interest_paid, error_message=error_message)
    return render_template('mortage.html', principal=principal, interest_paid=interest_paid, error_message=error_message)

if __name__ == '__main__':
    app.run()  
mortage.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mortgage Calculator</title>  
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gradient-to-r from-blue-300 via-blue-400 to-blue-500 min-h-screen flex items-center justify-center">
    <div class="max-w-md w-full p-6 bg-white shadow-md rounded-md">
        <h1 class="text-2xl font-semibold mb-4 text-blue-600">Mortgage Calculator</h1>
        {% if error_message %}
        <p class="text-red-500 mb-4">{{ error_message }}</p>
        {% endif %}
        <form method="POST">
            <div class="mb-4">
                <label for="principal" class="block text-gray-700 font-bold mb-2">Principal Amount ($):</label>
                <input type="number" step="0.01" name="principal" required class="border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring focus:border-blue-500 bg-blue-100">
            </div>
            <div class="mb-4">
                <label for="interest_rate" class="block text-gray-700 font-bold mb-2">Annual Interest Rate (%):</label>
                <input type="number" step="0.01" name="interest_rate" required class="border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring focus:border-blue-500 bg-blue-100">
            </div>
            <div class="mb-4">
                <label for="years" class="block text-gray-700 font-bold mb-2">Loan Term (Years):</label>
                <input type="number" step="0.01" name="years" required class="border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring focus:border-blue-500 bg-blue-100">
            </div>
            <button type="submit" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-full focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-opacity-50">
                Calculate
            </button>
        </form>
        {% if principal and interest_paid %}
        <div class="mt-4">
            <h2 class="text-lg font-semibold mb-2 text-blue-600">Results:</h2>
            <p class="text-gray-800">Principal Amount: ${{ principal }}</p>
            <p class="text-gray-800">Interest Paid: ${{ interest_paid }}</p>
        </div>
        {% endif %}
    </div>
</body>
</html>
Reply
#4
I'm not a fan of MS-Producs, but you should read this article: https://techcommunity.microsoft.com/t5/e...-p/3893439
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020