Jump to content

How to align currency right?


Recommended Posts

I wrote a skript to calculate something and want to align the currency in the MsgBox decimal or right. The output should look like this

10.00 €
100.00 €
1000.00 €

but at the moment it is centered. ;-(

This is the current code-snippet:

$ausgabe =( _
"Der Rabatt beträgt " &@TAB&@TAB& StringFormat("%10.2f", Round($rabatt_prozentsatz, 2)) & " %" &@CRLF& _
"Der Skonto beträgt " &@TAB&@TAB& StringFormat("%10.2f", Round($skonto_prozentsatz, 2)) & " %" &@CRLF& _ 
"______________________________" &@CRLF& _
"Listeneinkaufspreis " &@TAB&@TAB& StringFormat("%10.2f", Round($listenpreis, 2)) & " €" &@CRLF& _
"- Liefererrabatt " &@TAB&@TAB& StringFormat("%10.2f", Round($rabatt_absolut, 2)) & " €" &@CRLF& _
"= Zieleinkaufspreis " &@TAB&@TAB& StringFormat("%10.2f", Round($zieleinkaufspreis, 2)) & " €" &@CRLF& _
"- Liefererskonto " &@TAB&@TAB& StringFormat("%10.2f", Round($skonto_absolut, 2)) & " €" &@CRLF& _
"= Bareinkaufspreis " &@TAB&@TAB& StringFormat("%10.2f", Round($bareinkaufspreis, 2)) & " €" &@CRLF& _
"+ Bezugskosten " &@TAB&@TAB& StringFormat("%10.2f", Round($bezugskosten, 2)) & " €" &@CRLF& _
"= Bezugspreis " &@TAB&@TAB& StringFormat("%10.2f", Round($bezugspreis, 2)) & " €" &@CRLF)
 
MsgBox(0, "Rabatt (absolut)", $ausgabe)




Any ideas to get the currency formated?

Link to comment
Share on other sites

Maybe because you're using @TAB?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Can you post a small script we can run please. Also use the blue icon when posting AutoIt code.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

$pgmstart = InputBox("Programmstart", "Wollen Sie das Programm starten?", "ja")

If $pgmstart = "ja" Then
; Eingabe der gegebenen Zahlen: Listenpreis, Rabatt in Prozent, Skonto in Prozent, Bezugskosten

 $listenpreis = InputBox("Eingabe", "Bitte den Listenpreis (ohne Währung) eingeben: ", "10000.00")
 $rabatt_prozentsatz = InputBox("Eingabe", "Bitte den Rabatt (ohne ein Prozentzeichen) eingeben: ", "10") 
 $skonto_prozentsatz = InputBox("Eingabe", "Bitte den Skonto (ohne ein Prozentzeichen) eingeben: ", "20") 
 $bezugskosten = InputBox("Eingabe", "Bitte die Bezugskosten (ohne Währung) eingeben:", "50") 
 
 ; Verarbeitung (Berechnung) der benötigten Zahlen 
 $rabatt_absolut = $listenpreis * ($rabatt_prozentsatz / 100)
 $skonto_absolut = ($listenpreis - $rabatt_absolut) * ($skonto_prozentsatz / 100)
 $zieleinkaufspreis = $listenpreis - $rabatt_absolut
 $bareinkaufspreis = ($listenpreis - $rabatt_absolut - $skonto_absolut)
 $bezugspreis =  ($bareinkaufspreis + $bezugskosten)
 
$ausgabe =( _
"Der Rabatt beträgt " & StringFormat("%10.2f", Round($rabatt_prozentsatz, 2)) & " %" &@CRLF& _
"Der Skonto beträgt " & StringFormat("%10.2f", Round($skonto_prozentsatz, 2)) & " %" &@CRLF& _ 
"______________________________" &@CRLF& _
"Listeneinkaufspreis " & StringFormat("%10.2f", Round($listenpreis, 2)) & " €" &@CRLF& _
"- Liefererrabatt " & StringFormat("%10.2f", Round($rabatt_absolut, 2)) & " €" &@CRLF& _
"= Zieleinkaufspreis " & StringFormat("%10.2f", Round($zieleinkaufspreis, 2)) & " €" &@CRLF& _
"- Liefererskonto " &@TAB&@TAB& StringFormat("%10.2f", Round($skonto_absolut, 2)) & " €" &@CRLF& _
"= Bareinkaufspreis " &@TAB&@TAB& StringFormat("%10.2f", Round($bareinkaufspreis, 2)) & " €" &@CRLF& _
"+ Bezugskosten " &@TAB&@TAB& StringFormat("%10.2f", Round($bezugskosten, 2)) & " €" &@CRLF& _
"= Bezugspreis " &@TAB&@TAB& StringFormat("%10.2f", Round($bezugspreis, 2)) & " €" &@CRLF)

MsgBox(0, "Rabatt (absolut)", $ausgabe)

else

 MsgBox(0, "Ende", "Sie haben das Programm abgebrochen.")
EndIf

Exit

Thank you for the help.

That is the whole skript.

Link to comment
Share on other sites

  • Developers

Something for you to play with:

$pgmstart = "ja"

If $pgmstart = "ja" Then
    ; Eingabe der gegebenen Zahlen: Listenpreis, Rabatt in Prozent, Skonto in Prozent, Bezugskosten

    $listenpreis = "10000.00"
    $rabatt_prozentsatz = "10"
    $skonto_prozentsatz = "20"
    $bezugskosten = "50"

    ; Verarbeitung (Berechnung) der benötigten Zahlen
    $rabatt_absolut = $listenpreis * ($rabatt_prozentsatz / 100)
    $skonto_absolut = ($listenpreis - $rabatt_absolut) * ($skonto_prozentsatz / 100)
    $zieleinkaufspreis = $listenpreis - $rabatt_absolut
    $bareinkaufspreis = ($listenpreis - $rabatt_absolut - $skonto_absolut)
    $bezugspreis = ($bareinkaufspreis + $bezugskosten)

    $ausgabe = ( _
            "Der Rabatt beträgt  " & StringFormat("%10.2f", Round($rabatt_prozentsatz, 2)) & " %" & @CRLF & _
            "Der Skonto beträgt  " & StringFormat("%10.2f", Round($skonto_prozentsatz, 2)) & " %" & @CRLF & _
            "______________________________" & @CRLF & _
            "Listeneinkaufspreis " & StringFormat("%10.2f", Round($listenpreis, 2)) & " €" & @CRLF & _
            "- Liefererrabatt    " & StringFormat("%10.2f", Round($rabatt_absolut, 2)) & " €" & @CRLF & _
            "= Zieleinkaufspreis " & StringFormat("%10.2f", Round($zieleinkaufspreis, 2)) & " €" & @CRLF & _
            "- Liefererskonto    " & @TAB & @TAB & StringFormat("%10.2f", Round($skonto_absolut, 2)) & " €" & @CRLF & _
            "= Bareinkaufspreis  " & @TAB & @TAB & StringFormat("%10.2f", Round($bareinkaufspreis, 2)) & " €" & @CRLF & _
            "+ Bezugskosten      " & @TAB & @TAB & StringFormat("%10.2f", Round($bezugskosten, 2)) & " €" & @CRLF & _
            "= Bezugspreis       " & @TAB & @TAB & StringFormat("%10.2f", Round($bezugspreis, 2)) & " €" & @CRLF)

;~ MsgBox(0, "Rabatt (absolut)", $ausgabe)

    #include <GUIConstantsEx.au3>
    GUICreate("Rabatt (absolut)",400,200)
    GUICtrlCreateLabel($ausgabe,1,1,390,160)
    GUICtrlSetFont(-1, Default, Default, Default, "Courier New")
    GUISetState(@SW_SHOW)

    Do
        Local $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you very much, Jos. Your help solved my problem. Here is the final release for people who have similar questions.

#cs ----------------------------------------------------------------------------


 AutoIt Version: 3.3.8.1
 Author:         Uwe Wennmann


 Script Function:
Bezugspreisberechnung
 Version: 0.1


#ce ----------------------------------------------------------------------------


; Script Start - Add your code below here


$pgmstart = InputBox("Programmstart", "Wollen Sie das Programm starten?", "ja")


If $pgmstart = "ja" Then
; Eingabe der gegebenen Zahlen: Listenpreis, Rabatt in Prozent, Skonto in Prozent, Bezugskosten


 $listenpreis = InputBox("Eingabe", "Bitte den Listenpreis (ohne Währung) eingeben: ", "10000.00")
 $rabatt_prozentsatz = InputBox("Eingabe", "Bitte den Rabatt (ohne ein Prozentzeichen) eingeben: ", "10") 
 $skonto_prozentsatz = InputBox("Eingabe", "Bitte den Skonto (ohne ein Prozentzeichen) eingeben: ", "20") 
 $bezugskosten = InputBox("Eingabe", "Bitte die Bezugskosten (ohne Währung) eingeben:", "50") 


 ; Verarbeitung (Berechnung) der benötigten Zahlen 
 $rabatt_absolut = $listenpreis * ($rabatt_prozentsatz / 100)
 $skonto_absolut = ($listenpreis - $rabatt_absolut) * ($skonto_prozentsatz / 100)
 $zieleinkaufspreis = $listenpreis - $rabatt_absolut
 $bareinkaufspreis = ($listenpreis - $rabatt_absolut - $skonto_absolut)
 $bezugspreis =  ($bareinkaufspreis + $bezugskosten)


$ausgabe =( _
"Der Rabatt beträgt  " & StringFormat("%10.2f", Round($rabatt_prozentsatz, 2)) & " %" &@CRLF& _
"Der Skonto beträgt  " & StringFormat("%10.2f", Round($skonto_prozentsatz, 2)) & " %" &@CRLF& _ 
"________________________________" &@CRLF& _
"Listeneinkaufspreis " & StringFormat("%10.2f", Round($listenpreis, 2))        & " €" &@CRLF& _
"- Liefererrabatt    " & StringFormat("%10.2f", Round($rabatt_absolut, 2))     & " €" &@CRLF& _
"= Zieleinkaufspreis " & StringFormat("%10.2f", Round($zieleinkaufspreis, 2))  & " €" &@CRLF& _
"- Liefererskonto    " & StringFormat("%10.2f", Round($skonto_absolut, 2))     & " €" &@CRLF& _
"= Bareinkaufspreis  " & StringFormat("%10.2f", Round($bareinkaufspreis, 2))   & " €" &@CRLF& _
"+ Bezugskosten      " & StringFormat("%10.2f", Round($bezugskosten, 2))       & " €" &@CRLF& _
"= Bezugspreis       " & StringFormat("%10.2f", Round($bezugspreis, 2))        & " €" &@CRLF)


MsgBox(0, "Rabatt (absolut)", $ausgabe)


#include <GUIConstantsEx.au3>
    GUICreate("Bezugspreisberechnung",400,200) ; erstellt eine Dialogbox
    GUICtrlCreateLabel($ausgabe,1,1,390,160)
    GUICtrlSetFont(-1, Default, Default, Default, "Courier New")
    GUISetState(@SW_SHOW)


    ; Run the GUI until the dialog is closed
    Do
        Local $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE






else


 MsgBox(0, "Ende", "Sie haben das Programm abgebrochen.")
EndIf


Exit
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...