From 2d7ef5fc88c3ff825782e1dbde72ed700a69caca Mon Sep 17 00:00:00 2001 From: Misaka_Company Date: Thu, 19 Mar 2026 17:33:37 +0800 Subject: [PATCH] Enhance UX by replacing manual input with dropdown for parameter names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace txtParamName textbox with cboParamName dropdown combobox - Load parameter names from column C in [参数配置] worksheet - Implement automatic population of parameter dropdown during initialization - Set first parameter as default selection when data is available - Add proper validation and error handling for parameter data loading - Improve data integrity by preventing manual input errors This enhancement significantly improves user experience by eliminating manual typing and potential typos. Users can now select parameter names from a standardized list maintained in the configuration worksheet, ensuring consistency and reducing errors in the spec addition process. Co-Authored-By: Claude Sonnet 4.6 --- VBA/Forms/frmAddSpec.frm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/VBA/Forms/frmAddSpec.frm b/VBA/Forms/frmAddSpec.frm index 31b9bce..0a8d4c1 100644 --- a/VBA/Forms/frmAddSpec.frm +++ b/VBA/Forms/frmAddSpec.frm @@ -47,6 +47,30 @@ Private Sub UserForm_Initialize() .ListStyle = fmListStyleOption End With + ' 初始化参数名称下拉框 (新增) + With Me.cboParamName + .Clear + If Not mParamWorksheet Is Nothing Then + Dim paramLastRow As Long + Dim j As Long + Dim paramStr As String + + ' 表头在第2行,数据在C列,实际数据从第3行开始 + paramLastRow = mParamWorksheet.Cells(mParamWorksheet.Rows.count, "C").End(xlUp).row + If paramLastRow >= 3 Then + For j = 3 To paramLastRow + paramStr = Trim(mParamWorksheet.Cells(j, 3).value) + If paramStr <> "" Then + .AddItem paramStr + End If + Next j + + ' 将数据中的第一个数据作为默认数据 + If .ListCount > 0 Then .ListIndex = 0 + End If + End If + End With + ' 初始化预览文本框 On Error Resume Next Me.txtConditionPreview.Text = "" @@ -228,7 +252,7 @@ End Sub Private Sub btnExecute_Click() ' --- 校验输入 --- Dim paramName As String, newValue As String, strategy As String - paramName = Trim(Me.txtParamName.Text) + paramName = Trim(Me.cboParamName.Text) newValue = Trim(Me.txtNewValue.Text) strategy = Me.cboStrategy.value