"优化"了一点,代码行数降低了一部分,不过感觉创建Radio还可以再优化,奈何一次性把所有Radios添加进数组可以创建成功,但捕捉消息会有问题,明明只有54个Radio,捕捉到Case[0][0] to Case [5][10]的消息可以超过这个数量,估计是循环的时候创建Group占用了,不会玩又改回单个创建Group和Radio组了
另外还有一个问题,XP上Radio的颜色是正常的,Win7下Radio文字颜色没生效,啥情况???
#region AutoIt3Wrapper 预编译参数(常用参数)
#AutoIt3Wrapper_Icon=F:\AU3脚本\图标\hidao.ico ;图标,支持EXE,DLL,ICO
#AutoIt3Wrapper_OutFile=R_Calc.exe ;输出文件名
#AutoIt3Wrapper_OutFile_Type=exe ;文件类型
#AutoIt3Wrapper_Compression=9 ;压缩等级
#AutoIt3Wrapper_UseUPX=y ;使用压缩
#AutoIt3Wrapper_Res_Comment=R_Calc ;注释
#AutoIt3Wrapper_Res_Description=电阻计算器;详细信息
#AutoIt3Wrapper_Res_Fileversion=0.2.2023.913
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=;p ;自动更新版本
#AutoIt3Wrapper_Res_LegalCopyright=邪恶海盗;版权
#endregion AutoIt3Wrapper 预编译参数(常用参数)
;#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
;#include <TabConstants.au3>
;#include <WindowsConstants.au3>
#NoTrayIcon
#region ### START Koda GUI section ### Form=f:\au3脚本\色环电阻.kxf
Dim $Radios0[10][5] = [[0, 0, '黑=0', 0x000000, 0],[0, 1, '棕=1', 0x800000, 1],[0, 2, '红=2', 0xFF0000, 2],[0, 3, '橙=3', 0xFFA500, 3],[0, 4, '黄=4', 0xFFFF00, 4], _
[0, 5, '绿=5', 0x008000, 5],[0, 6, '蓝=6', 0x0000FF, 6],[0, 7, '紫=7', 0x800080, 7],[0, 8, '灰=8', 0x808080, 8],[0, 9, '白=9', 0xFFFFFF, 9]]
Dim $Radios1[10][5] = [[1, 0, '黑=0', 0x000000, 0],[1, 1, '棕=1', 0x800000, 1],[1, 2, '红=2', 0xFF0000, 2],[1, 3, '橙=3', 0xFFA500, 3],[1, 4, '黄=4', 0xFFFF00, 4], _
[1, 5, '绿=5', 0x008000, 5],[1, 6, '蓝=6', 0x0000FF, 6],[1, 7, '紫=7', 0x800080, 7],[1, 8, '灰=8', 0x808080, 8],[1, 9, '白=9', 0xFFFFFF, 9]]
Dim $Radios2[10][5] = [[2, 0, '黑=0', 0x000000, 0],[2, 1, '棕=1', 0x800000, 1],[2, 2, '红=2', 0xFF0000, 2],[2, 3, '橙=3', 0xFFA500, 3],[2, 4, '黄=4', 0xFFFF00, 4], _
[2, 5, '绿=5', 0x008000, 5],[2, 6, '蓝=6', 0x0000FF, 6],[2, 7, '紫=7', 0x800080, 7],[2, 8, '灰=8', 0x808080, 8],[2, 9, '白=9', 0xFFFFFF, 9]]
Dim $Radios3[10][5] = [[3, 0, '黑=0', 0x000000, 0],[3, 1, '棕=1', 0x800000, 1],[3, 2, '红=2', 0xFF0000, 2],[3, 3, '橙=3', 0xFFA500, 3],[3, 4, '黄=4', 0xFFFF00, 4], _
[3, 5, '绿=5', 0x008000, 5],[3, 6, '蓝=6', 0x0000FF, 6],[3, 7, '紫=7', 0x800080, 7],[3, 8, '金=-1', 0xFFD700, -1],[3, 9, '银=-2', 0xC0C0C0, -2]]
Dim $Radios4[8][5] = [[4, 0, '棕=±1', 0x800000, '±1'],[4, 1, '红=±2', 0xFF0000, '±2'],[4, 2, '绿=±0.5', 0x008000, '±0.5'],[4, 3, '蓝=±0.25', 0x0000FF, '±0.25'],[4, 4, '紫=±0.1', 0x800080, '±0.1'], _
[4, 5, '灰=±0.05', 0x808080, '±0.05'],[4, 6, '金=±5', 0xFFD700, '±5'],[4, 7, '银=±10', 0xC0C0C0, '±10']]
Dim $Radios5[6][5] = [[5, 0, '棕=100ppm', 0x800000, '100ppm/℃'],[5, 1, '红=50ppm', 0xFF0000, '50ppm/℃'],[5, 2, '橙=15ppm', 0xFFA500, '15ppm/℃'],[5, 3, '黄=25ppm', 0xFFFF00, '25ppm/℃'],[5, 4, '蓝=10ppm', 0x0000FF, '10ppm/℃'], _
[5, 5, '紫=5ppm', 0x800080, '5ppm/℃']]
Dim $i1 = 0, $i2 = 0, $i3 = 0, $i4 = 0, $i5 = 0, $i6 = 0
Dim $RdoR[6][10]
Dim $Group1_6[6] = ['第1位', '第2位', '第3位', '倍率(10^n)', '误差(%)', '温度系数(/℃)']
$Form1_1 = GUICreate("电阻计算器 v0.2 20230913", 640, 375)
$oeminfo = GUICtrlCreateLabel('邪恶海盗 www.hidao.org', 480, 1, 160, 18, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10)
GUICtrlSetColor(-1, 0x0000FF)
;GUISetFont(14)
$Tab1 = GUICtrlCreateTab(0, 0, 640, 375)
$TabSheet1 = GUICtrlCreateTabItem("色环转阻值")
$Group0 = GUICtrlCreateGroup($Group1_6[0], 10 + 95 * 0, 85, 85, 275)
For $Rn1_6 = 0 To 9
$RdoR[0][$Rn1_6] = GUICtrlCreateRadio($Radios0[$Rn1_6][2], 15 + 0 * 95, 105 + 25 * $Rn1_6, 75, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Radios0[$Rn1_6][3])
Next
GUICtrlSetColor($RdoR[0][4], 0x000000)
GUICtrlSetColor($RdoR[0][9], 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group1 = GUICtrlCreateGroup($Group1_6[1], 10 + 95 * 1, 85, 85, 275)
For $Rn1_6 = 0 To 9
$RdoR[1][$Rn1_6] = GUICtrlCreateRadio($Radios1[$Rn1_6][2], 15 + 1 * 95, 105 + 25 * $Rn1_6, 75, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Radios1[$Rn1_6][3])
Next
GUICtrlSetColor($RdoR[1][4], 0x000000)
GUICtrlSetColor($RdoR[1][9], 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup($Group1_6[2], 10 + 95 * 2, 85, 85, 275)
For $Rn1_6 = 0 To 9
$RdoR[2][$Rn1_6] = GUICtrlCreateRadio($Radios2[$Rn1_6][2], 15 + 2 * 95, 105 + 25 * $Rn1_6, 75, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Radios2[$Rn1_6][3])
Next
GUICtrlSetColor($RdoR[2][4], 0x000000)
GUICtrlSetColor($RdoR[2][9], 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup($Group1_6[3], 10 + 95 * 3, 85, 85, 275)
For $Rn1_6 = 0 To 9
$RdoR[3][$Rn1_6] = GUICtrlCreateRadio($Radios3[$Rn1_6][2], 15 + 3 * 95, 105 + 25 * $Rn1_6, 75, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Radios3[$Rn1_6][3])
Next
GUICtrlSetColor($RdoR[3][4], 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup($Group1_6[4], 10 + 95 * 4, 85, 115, 275)
For $Rn1_6 = 0 To 7
$RdoR[4][$Rn1_6] = GUICtrlCreateRadio($Radios4[$Rn1_6][2], 15 + 4 * 95, 105 + 25 * $Rn1_6, 105, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Radios4[$Rn1_6][3])
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup($Group1_6[5], 10 + 95 * 4 + 115 + 10, 85, 115, 275)
For $Rn1_6 = 0 To 5
$RdoR[5][$Rn1_6] = GUICtrlCreateRadio($Radios5[$Rn1_6][2], 15 + 4 * 95 + 115 + 10, 105 + 25 * $Rn1_6, 105, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Radios5[$Rn1_6][3])
Next
GUICtrlSetColor($RdoR[5][3], 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState($Group2, $GUI_HIDE)
GUICtrlSetState($Group4, $GUI_HIDE)
GUICtrlSetState($Group5, $GUI_HIDE)
For $Ri = 0 To 9
GUICtrlSetState($RdoR[2][$Ri], $GUI_HIDE)
GUICtrlSetState($RdoR[4][$Ri], $GUI_HIDE)
GUICtrlSetState($RdoR[5][$Ri], $GUI_HIDE)
Next
$Radio30 = GUICtrlCreateRadio("3环电阻", 10, 30, 90, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio40 = GUICtrlCreateRadio("4环电阻", 10, 55, 90, 25)
$Radio50 = GUICtrlCreateRadio("5环电阻", 105, 30, 90, 25)
$Radio60 = GUICtrlCreateRadio("6环电阻", 105, 55, 90, 25)
GUICtrlCreateLabel(" ", 200, 54, 10, 2, $SS_ETCHEDHORZ)
GUICtrlCreateLabel(" ", 205, 35, 180, 40, $SS_GRAYFRAME)
GUICtrlCreateLabel(" ", 385, 54, 10, 2, $SS_ETCHEDHORZ)
$Label01 = GUICtrlCreateLabel(" ", 220, 34, 15, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Radios0[0][3])
$Label02 = GUICtrlCreateLabel(" ", 245, 34, 15, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Radios1[0][3])
$Label03 = GUICtrlCreateLabel(" ", 270, 34, 15, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Radios2[0][3])
$Label04 = GUICtrlCreateLabel(" ", 295, 34, 15, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Radios3[0][3])
$Label05 = GUICtrlCreateLabel(" ", 330, 34, 15, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Radios4[0][3])
$Label06 = GUICtrlCreateLabel(" ", 355, 34, 15, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Radios5[0][3])
GUICtrlSetState($Label03, $GUI_HIDE)
GUICtrlSetState($Label05, $GUI_HIDE)
GUICtrlSetState($Label06, $GUI_HIDE)
$Lab1 = GUICtrlCreateLabel("计算过程及结果", 400, 25, 230, 25, $SS_SUNKEN + $SS_CENTERIMAGE)
;GUICtrlSetFont(-1,10)
$Lab2 = GUICtrlCreateLabel("计算过程及结果", 400, 50, 230, 25, $SS_SUNKEN + $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 11)
$TabSheet4 = GUICtrlCreateTabItem("串并联阻值计算")
;GUICtrlSetState(-1, $GUI_SHOW)
$Group7 = GUICtrlCreateGroup("串联阻值计算", 10, 35, 620, 135)
$InputR11 = GUICtrlCreateInput("", 24, 55, 80, 25, $SS_CENTER)
$Combo11 = GUICtrlCreateCombo("", 104, 55, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR12 = GUICtrlCreateInput("", 174, 55, 80, 25, $SS_CENTER)
$Combo12 = GUICtrlCreateCombo("", 254, 55, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
GUICtrlCreateLabel("=", 314, 55, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
$InputR13 = GUICtrlCreateInput("?", 354, 55, 130, 25, $SS_CENTER)
GUICtrlSetState(-1, $GUI_DISABLE)
$ButtonR1 = GUICtrlCreateButton("计算", 500, 54, 65, 25)
$InputR21 = GUICtrlCreateInput("", 24, 95, 80, 25, $SS_CENTER)
$Combo21 = GUICtrlCreateCombo("", 104, 95, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR22 = GUICtrlCreateInput("?", 174, 95, 130, 25, $SS_CENTER)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel("=", 314, 97, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
$InputR23 = GUICtrlCreateInput("", 354, 95, 80, 25, $SS_CENTER )
$Combo23 = GUICtrlCreateCombo("", 434, 95, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$ButtonR2 = GUICtrlCreateButton("计算", 500, 94, 65, 25)
GUICtrlCreateLabel('原理: R1 + R2 = R3', 30, 140, 200, 25)
GUICtrlSetFont(-1, 12)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group8 = GUICtrlCreateGroup("并联阻值计算", 10, 180, 620, 135)
$InputR31 = GUICtrlCreateInput("", 24, 200, 80, 25, $SS_CENTER )
$Combo31 = GUICtrlCreateCombo("", 104, 200, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR32 = GUICtrlCreateInput("", 174, 200, 80, 25, $SS_CENTER )
$Combo32 = GUICtrlCreateCombo("", 254, 200, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
GUICtrlCreateLabel("=", 314, 200, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
$InputR33 = GUICtrlCreateInput("?", 354, 200, 130, 25, $SS_CENTER )
GUICtrlSetState(-1, $GUI_DISABLE)
$ButtonR3 = GUICtrlCreateButton("计算", 500, 200, 65, 25)
$InputR41 = GUICtrlCreateInput("", 24, 240, 80, 25, $SS_CENTER )
$Combo41 = GUICtrlCreateCombo(" ", 104, 240, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR42 = GUICtrlCreateInput("?", 174, 240, 130, 25, $SS_CENTER )
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel("=", 314, 240, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
$InputR43 = GUICtrlCreateInput("", 354, 240, 80, 25, $SS_CENTER )
$Combo43 = GUICtrlCreateCombo("", 434, 240, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$ButtonR4 = GUICtrlCreateButton("计算", 500, 240, 65, 25)
GUICtrlCreateLabel('原理: 1/R1 + 1/R2 = 1/R3', 30, 285, 200, 25)
GUICtrlSetFont(-1, 12)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $oeminfo
ShellExecute('www.hidao.org')
Case $Radio30
GUICtrlSetState($Label03, $GUI_HIDE)
GUICtrlSetState($Label05, $GUI_HIDE)
GUICtrlSetState($Label06, $GUI_HIDE)
GUICtrlSetState($Group2, $GUI_HIDE)
GUICtrlSetState($Group4, $GUI_HIDE)
GUICtrlSetState($Group5, $GUI_HIDE)
For $Ri = 0 To 9
GUICtrlSetState($RdoR[2][$Ri], $GUI_HIDE)
GUICtrlSetState($RdoR[4][$Ri], $GUI_HIDE)
GUICtrlSetState($RdoR[5][$Ri], $GUI_HIDE)
Next
_Calc()
Case $Radio40
GUICtrlSetState($Label03, $GUI_HIDE)
GUICtrlSetState($Label05, $GUI_SHOW)
GUICtrlSetState($Label06, $GUI_HIDE)
GUICtrlSetState($Group2, $GUI_HIDE)
GUICtrlSetState($Group4, $GUI_SHOW)
GUICtrlSetState($Group5, $GUI_HIDE)
For $Ri = 0 To 9
GUICtrlSetState($RdoR[2][$Ri], $GUI_HIDE)
Next
For $Ri = 0 To 7
GUICtrlSetState($RdoR[4][$Ri], $GUI_SHOW)
Next
For $Ri = 0 To 5
GUICtrlSetState($RdoR[5][$Ri], $GUI_HIDE)
Next
_Calc()
Case $Radio50
GUICtrlSetState($Label03, $GUI_SHOW)
GUICtrlSetState($Label05, $GUI_SHOW)
GUICtrlSetState($Label06, $GUI_HIDE)
GUICtrlSetState($Group2, $GUI_SHOW)
GUICtrlSetState($Group4, $GUI_SHOW)
GUICtrlSetState($Group5, $GUI_HIDE)
For $Ri = 0 To 9
GUICtrlSetState($RdoR[2][$Ri], $GUI_SHOW)
GUICtrlSetState($RdoR[4][$Ri], $GUI_SHOW)
Next
For $Ri = 0 To 5
GUICtrlSetState($RdoR[5][$Ri], $GUI_HIDE)
Next
_Calc()
Case $Radio60
GUICtrlSetState($Label03, $GUI_SHOW)
GUICtrlSetState($Label05, $GUI_SHOW)
GUICtrlSetState($Label06, $GUI_SHOW)
GUICtrlSetState($Group2, $GUI_SHOW)
GUICtrlSetState($Group4, $GUI_SHOW)
GUICtrlSetState($Group5, $GUI_SHOW)
For $Ri = 0 To 9
GUICtrlSetState($RdoR[2][$Ri], $GUI_SHOW)
GUICtrlSetState($RdoR[4][$Ri], $GUI_SHOW)
Next
For $Ri = 0 To 5
GUICtrlSetState($RdoR[5][$Ri], $GUI_SHOW)
Next
_Calc()
Case $RdoR[0][0] To $RdoR[0][9]
$i1 = $nMsg - $RdoR[0][0]
;MsgBox(0,'',$Radios0[$i1][3])
_Calc()
Case $RdoR[1][0] To $RdoR[1][9]
$i2 = $nMsg - $RdoR[1][0]
;MsgBox(0,'',$Radios1[$i2][4])
_Calc()
Case $RdoR[2][0] To $RdoR[2][9]
$i3 = $nMsg - $RdoR[2][0]
_Calc()
Case $RdoR[3][0] To $RdoR[3][9]
$i4 = $nMsg - $RdoR[3][0]
_Calc()
Case $RdoR[4][0] To $RdoR[4][7]
$i5 = $nMsg - $RdoR[4][0]
_Calc()
Case $RdoR[5][0] To $RdoR[5][5]
$i6 = $nMsg - $RdoR[5][0]
_Calc()
Case $ButtonR1
$R11 = GUICtrlRead($InputR11) * _Rx(GUICtrlRead($Combo11))
$R12 = GUICtrlRead($InputR12) * _Rx(GUICtrlRead($Combo12))
GUICtrlSetData($InputR13, _R2R($R11 + $R12))
Case $ButtonR2
$R21 = GUICtrlRead($InputR21) * _Rx(GUICtrlRead($Combo21))
$R23 = GUICtrlRead($InputR23) * _Rx(GUICtrlRead($Combo23))
GUICtrlSetData($InputR22, _R2R($R23 - $R21))
Case $ButtonR3
$R31 = GUICtrlRead($InputR31) * _Rx(GUICtrlRead($Combo31))
$R32 = GUICtrlRead($InputR32) * _Rx(GUICtrlRead($Combo32))
GUICtrlSetData($InputR33, _R2R(($R31 * $R32) / ($R31 + $R32)))
Case $ButtonR4
$R41 = GUICtrlRead($InputR41) * _Rx(GUICtrlRead($Combo41))
$R43 = GUICtrlRead($InputR43) * _Rx(GUICtrlRead($Combo43))
GUICtrlSetData($InputR42, _R2R(($R41 * $R43) / ($R41 - $R43)))
EndSwitch
WEnd
Func _Calc()
GUICtrlSetBkColor($Label01, $Radios0[$i1][3])
GUICtrlSetBkColor($Label02, $Radios1[$i2][3])
GUICtrlSetBkColor($Label03, $Radios2[$i3][3])
GUICtrlSetBkColor($Label04, $Radios3[$i4][3])
GUICtrlSetBkColor($Label05, $Radios4[$i5][3])
GUICtrlSetBkColor($Label06, $Radios5[$i6][3])
If GUICtrlRead($Radio30) = $GUI_CHECKED Then
$Var1 = ' ' & $Radios0[$i1][4] & ' ' & $Radios1[$i2][4] & ' ×10^' & $Radios3[$i4][4] & " = "
$Var2 = ($Radios0[$i1][4] & $Radios1[$i2][4]) * 10 ^ $Radios3[$i4][4]
$Var3 = '(误差:' & '±20' & '%)'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ×10^' & $i4 & " = " & ($i1 & $i2) * 10 ^ $i4 & " Ω" & ' (误差:' & '20%' & ')')
EndIf
If GUICtrlRead($Radio40) = $GUI_CHECKED Then
$Var1 = ' ' & $Radios0[$i1][4] & ' ' & $Radios1[$i2][4] & ' ×10^' & $Radios3[$i4][4] & " = "
$Var2 = ($Radios0[$i1][4] & $Radios1[$i2][4]) * 10 ^ $Radios3[$i4][4]
$Var3 = '(误差:' & $Radios4[$i5][4] & '%)'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ×10^' & $i4 & " = " & ($i1 & $i2) * 10 ^ $i4 & " Ω" & ' (误差:' & $i5 & ')')
EndIf
If GUICtrlRead($Radio50) = $GUI_CHECKED Then
$Var1 = ' ' & $Radios0[$i1][4] & ' ' & $Radios1[$i2][4] & ' ' & $Radios2[$i3][4] & ' ×10^' & $Radios3[$i4][4] & " = "
$Var2 = ($Radios0[$i1][4] & $Radios1[$i2][4] & $Radios2[$i3][4]) * 10 ^ $Radios3[$i4][4]
$Var3 = '(误差:' & $Radios4[$i5][4] & '%)'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ' & $i3 & ' ×10^' & $i4 & " = " & ($i1 & $i2 & $i3) * 10 ^ $i4 & " Ω" & ' (误差:' & $i5 & ')')
EndIf
If GUICtrlRead($Radio60) = $GUI_CHECKED Then
$Var1 = ' ' & $Radios0[$i1][4] & ' ' & $Radios1[$i2][4] & ' ' & $Radios2[$i3][4] & ' ×10^' & $Radios3[$i4][4] & " = "
$Var2 = ($Radios0[$i1][4] & $Radios1[$i2][4] & $Radios2[$i3][4]) * 10 ^ $Radios3[$i4][4]
$Var3 = '(误差:' & $Radios4[$i5][4] & '% 温度系数:' & $Radios5[$i6][4] & ')'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ' & $i3 & ' ×10^' & $i4 & " = " & ($i1 & $i2 & $i3) * 10 ^ $i4 & " Ω" & ' (误差:±' & $i5 & ',温度:)' & $i6)
EndIf
GUICtrlSetData($Lab1, $Var1 & _R2R($Var2))
GUICtrlSetData($Lab2, $Var3)
EndFunc ;==>_Calc
Func _R2R($R2R)
Switch $R2R
Case $R2R < 999
Return Round($R2R, 2) & ' Ω'
Case 1000 To 999999
Return Round($R2R / 1000, 2) & " KΩ"
Case Else
Return Round($R2R / 1000000, 2) & " MΩ"
EndSwitch
EndFunc ;==>_R2R
Func _Rx($Rx)
Switch $Rx
Case 'Ω'
Return 1
Case 'KΩ'
Return 1000
Case 'MΩ'
Return 1000000
EndSwitch
EndFunc ;==>_Rx
|