Jump to content

Recommended Posts

Hi everyone,

I'm terribly sorry if this is not the place to ask for this question, but I'm poor at developing scripts so I'm asking for your help or guidance.

I want to make a script where I enter a number and it automatically calculates it into the answer.

If I were using excel the formula would be "=(A1/(1-5,5%))*(1+20%)", and it would probably be easy to figure out a way to make a .exe or something from it running through excel, but I'll mostly be running this on a computer without the office package installed(only 365).

What I have in mind is a small window where I write the number that would be in cell A1, let's say 100 - and a new window would pop up and show 126,98(two decimals required).

I wonder if this is even possible at all, I guess it'd require huge .txt files with numbers to even make sense. I'm very new - point blanc.

Thank you, and my deepest apologies if this is the wrong place to ask or if it's an "impossible" task.

Link to post
Share on other sites
  • Solution

Maybe something like:

#include <GUIConstantsEx.au3>

Global $g_iInput, $g_idInput, $g_idOutput

Func _Example()
    GUICreate("Calculate", 110, 90)
    $g_idInput = GUICtrlCreateInput("", 5, 5, 100, 20)
    $g_idOutput = GUICtrlCreateInput("", 5, 30, 100, 20)
    GUICtrlSetState($g_idOutput, $GUI_DISABLE)
    Local $idOutput = GUICtrlCreateButton("Copy to Clipboard", 5, 55, 100, 30)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
            Case $idOutput

Func _Calculate()
    Local $iInput = Int(GUICtrlRead($g_idInput))
    If $iInput = $g_iInput Then Return
    Local $sCalculate = Round(($iInput/(1-5.5/100))*(1+20/100), 2)
    GUICtrlSetData($g_idOutput, $sCalculate)
    $g_iInput = $iInput


Link to post
Share on other sites


Streamlined (I guess more correct) calculation:

Local $sCalculate = Round($iInput * 0.945 * 1.2, 2)

Substracting 5.5% is equivalent to multiplying by: (100 - 5.5) / 100 which is 0.945

Adding 20% is equivalent to multiplying by: (100 + 20) / 100 which is 1.2

You divide by 0.945, so you end up adding around 5.82% which I guess isn't what you want: 100 / 0.945 = 105.820105820106

With input 100 the (I guess correct) result is: 113.40

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...