Jump to content
Sign in to follow this  
MyEarth

"proportional" vaule

Recommended Posts

MyEarth

Hi, if i have:

$a = 1280
$b = 720

and i want to change the $a to:

$a = 752

How to make the $b value proprotional to $a like this?

$a = 752
$b = 423

I'd like also the opposite, if i change $b i want the $a to be proportional to $b

Thanks

Edited by MyEarth

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, MyEarth. Why not set a third variable, which could even be an inputbox, to do the calculation for you?

$a = 1280
$b = 720
$c = InputBox("Calculate Vars Example", "What would you like the calculation to be?")

$a = $a / $c
$b = $b / $c

MsgBox(0, "", "$a is now " & $a & ". $b is now " & $b)

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
MyEarth

I need to set manually the value, with your solution i can't write it, example, $a = 124.5 then calculate $b or viceversa

Edited by MyEarth

Share this post


Link to post
Share on other sites
water

$a1 = 1280
$a2 = 752
$b1 = 720
$b2 = $b1 * $a2 / $a1
ConsoleWrite($b2 & @LF)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
MyEarth

Thanks, now i have understood ;)

Share this post


Link to post
Share on other sites
water

My example doesn't work when $a1 = 0.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
MyEarth

It's not a problem, $a and $b is always <> 0

Sorry, but if i want to calculate $a starting from $b what type of calc i need to do?

Share this post


Link to post
Share on other sites
water

a2 = (a1xb2)/b1

Simple math.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
MyEarth

Cool, thanks again ;)

Share this post


Link to post
Share on other sites
water
:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
AZJIO

Mathematics, proportions, the 5th class at school

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>

Global $k = 0
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
$GUI = GUICreate("horis", 1020, 285, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_HSCROLL))

$slider1 = GUICtrlCreateSlider(10, 5, 1000, 30)
GUICtrlSetLimit(-1, 1000, 0)
$hSlider_Handle1 = GUICtrlGetHandle(-1)
GUICtrlSetData(-1, 120)

$slider2 = GUICtrlCreateSlider(10, 35, 1000, 30)
GUICtrlSetLimit(-1, 1000, 0)
$hSlider_Handle2 = GUICtrlGetHandle(-1)
GUICtrlSetData(-1, 72)

$koef = 72/120

$condition = GUICtrlCreateLabel('', 10, 75, 300, 55)
GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF) ; _WinAPI_LoWord
    Local $value = BitShift($wParam, 16) ; _WinAPI_HiWord

    Switch $lParam
        Case $hSlider_Handle1
            $sMsg = 'Slider = 1' & @LF & 'value = '
            Switch $nScrollCode
                Case $SB_THUMBTRACK
                    $sMsg &= $value & @LF & 'mode = Keeping by the left button of a mouse'
                Case $SB_THUMBPOSITION
                    $sMsg &= $value & @LF & 'mode = Trundle mouse'
                Case $SB_LINELEFT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Arrow L/Up'
                Case $SB_LINERIGHT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Arrow R/Down'
                Case $SB_PAGELEFT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Click Left'
                Case $SB_PAGERIGHT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Click R'
            EndSwitch
            If $nScrollCode <> 8 Then
                GUICtrlSetData($condition, $sMsg)
                GUICtrlSetData($slider2, $value*$koef)
            EndIf
        Case $hSlider_Handle2
            If $nScrollCode = $SB_THUMBTRACK Then
                GUICtrlSetData($condition, '2 - ' & $value)
                GUICtrlSetData($slider1, $value/$koef)
            EndIf
        Case 0
            If $nScrollCode = $SB_THUMBTRACK Then GUICtrlSetData($condition, '3 - ' & $value)
    EndSwitch

    $k += 1
    WinSetTitle($GUI, '', 'call ' & $k & ', c=' & $nScrollCode & ', v=' & $value)

    Return $GUI_RUNDEFMSG
EndFunc

Share this post


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
Sign in to follow this  

×