# mAh mWh Calculator

A little while ago, I wrote an article Convert mAh to mWh and mWh to mAh for Notebook Laptop Batteries that provided the calculations needed to convert from mAh to mWh and vice versa. The intent was to simplify the navigation in researching the purchase of a replacement battery. As many battery manufacturers present different pieces of information which makes it difficult to compare exact specification and find that perfect replacement battery. In this article, I present to you a calculator.

Using AutoIt and Koda Form Designer to create this calculator, I had issues getting my version to completely work without bugs.

I had put my code out on stackoverflow to see if someone would help identify the problem that existed in my code. Someone was kind enough to respond and with that here is the complete working code.

```#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

\$Form1 = GUICreate("mAh mWh Calculator", 336, 210, 682, 127)

\$capacity = GUICtrlCreateInput("", 224, 48, 81, 21)

\$Volt=GUICtrlCreateInput("", 224, 96, 81, 21)

\$Calculate = GUICtrlCreateButton("Calculate", 104, 136, 75, 25)
\$Input2 = GUICtrlCreateInput("", 184, 136, 121, 21)
GUICtrlSetState (\$Input2, \$GUI_DISABLE)

\$Label3 = GUICtrlCreateLabel("Calculate between milliampere-hour and millwatt-hour", 16, 16, 304, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
\$Label4 = GUICtrlCreateLabel("Select the appropriate radio button:", 48, 72, 170, 17)
\$Label1 = GUICtrlCreateLabel("Enter the mAh or mWh value for the battery:", 8, 48, 211, 17)
\$Label2 = GUICtrlCreateLabel("Enter the battery voltage:", 96, 96, 123, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While True
Switch GUIGetMsg()
Case \$GUI_EVENT_CLOSE
Exit

Case \$Calculate
If GUICtrlRead(\$capacity) == 0 Then ContinueLoop
If GUICtrlRead(\$Volt) == 0 Then ContinueLoop

;mAh checked
\$Ah = (\$mAh*1000)