Re: [AHK-] 如何两栏数字同步变动?

楼主: panex0845 (胖克思)   2022-01-06 21:29:38
※ 引述《Sylph (炁+盆满钵满)》之铭言:
: 如图,有上下两个字段,
: 我想要上栏改2时,下栏自动变60;
: 同理,下栏改30时,上栏自动变1。
: 请问撰写思路应该是怎么样?
: https://i.imgur.com/V6Gjl2X.jpg
这板板主不做事 板上废文充斥
最后一次帮忙解答 两天后自删 看到是缘分 没看到我也没办法
global exchangeRate := {"NTD":1, "USD":27.66, "HKD":3.55
, "JPY":0.24, "AUD":19.83, "GBP":37.44}
Gui, 1:New
Gui, 1:Add, Text, x10 y10, 简易汇率计算机,不对计算结果负任何责任
for k, v in exchangeRate {
Gui, 1:Add, Text, x10 y+10 w50, %k%
Gui, 1:Add, Edit, x+10 yp-3 gexchange w150 v%k%, 0
}
Gui, 1:Show, , exchange
return
exchange() {
GuicontrolGet, userinput, , % A_GuiControl
if userinput is not number
return
_NTD := 1 * exchangeRate[A_GuiControl] * userinput
for cur, FX in exchangeRate {
if (cur=A_GuiControl)
Continue
GuiControl, -g, % cur
calc := (cur="NTD") ? _NTD : _NTD / FX
GuiControl,, % cur, % FormatexchangeRate(calc)
GuiControl, +gexchange, % cur
}
}
FormatexchangeRate(number) {
effective := Round(number, 4)
comma := RegexReplace(effective, "(\d)(?=(?:\d{3})+(?:\.))", "$1,")
return RegexReplace(comma, "(\.\d+?)0+\b", "$1")
}
GuiClose(){
ExitApp
}
作者: Sylph (仙客来)   2022-01-08 08:10:00
原来如此,谢谢提供撰写的思路!

Links booklink

Contact Us: admin [ a t ] ucptt.com