# "proportional" vaule

## Recommended Posts

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 on other sites

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)```

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

##### Share on other sites

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 on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

##### Share on other sites

Thanks, now i have understood

##### Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

##### Share on other sites

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 on other sites

a2 = (a1xb2)/b1

Simple math.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

##### Share on other sites

Cool, thanks again

##### Share on other sites

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

##### Share on other sites

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
\$sMsg &= \$value & @LF & 'mode = Arrow L/Up'
Case \$SB_LINERIGHT
\$sMsg &= \$value & @LF & 'mode = Arrow R/Down'
Case \$SB_PAGELEFT
\$sMsg &= \$value & @LF & 'mode = Click Left'
Case \$SB_PAGERIGHT
\$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```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...