- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
5#
發表於 2012-8-16 16:15
| 只看該作者
本帖最後由 GBKEE 於 2012-8-16 16:17 編輯
回復 4# baiecesi
依你附檔的表單所寫的程式碼 試試看 應是這方面的作法- Dim Ar()
- Private Sub UserForm_Initialize()
- 'Initialize 事件 發生在一個物件載入後,但尚未顯示的時候。
- ComboBox3.List = Array("Type1", "Type2", "Type3") 'B(總值) 的選項
- 'B(總值) 的選項 可指向工作表的位置
- ReDim Ar(UBound(ComboBox3.List)) '重置陣列元素數
- '------因子選項 可指向工作表的位置
- Ar(0) = Array(1.15, 1.25) 'B(總值) 選項1 的因子選項
- Ar(1) = Array(2.5, 5) 'B(總值) 選項2 的因子選項
- '------選項3 的因子選項 請自修改
- ' Ar(2) = Array(2.5, 5) 'B(總值) 選項3 的因子選項
- TextBox1.TabIndex = 1 '重新設定表單上控制項的 TabIndex 順序
- ComboBox3.TabIndex = 2
- ComboBox1.TabIndex = 3
- End Sub
- Private Sub ComboBox3_Change()
- ComboBox1.Clear
- Label5.Caption = ""
- If ComboBox3.ListIndex > -1 Then ComboBox1.List = Ar(ComboBox3.ListIndex)
-
- End Sub
- Private Sub CommandButton1_Click()
- Dim xT(1 To 3) As Double
- If ComboBox3.ListIndex = -1 Or ComboBox3.ListIndex = -1 Then
- Label5.Caption = "ComboBox1.Text * ComboBox3.Text"
- Else
- Select Case ComboBox3.ListIndex '
- Case 0 'Type1
- xT(1) = 7.58
- xT(2) = 0.8
- Case 1 'Type2
- xT(1) = 7.9661
- xT(2) = 0.8
- Case 2 'Type3
- xT(1) = 8.1238
- xT(2) = 0.7243
- End Select
- xT(3) = Application.Evaluate("Exp(" & xT(1) & "+" & xT(2) & "* Ln(" & Val(TextBox1) & "))") / 1000
- Label5.Caption = Round((550 / 500) * xT(3) * Val(ComboBox1), 2)
- End If
- End Sub
- Private Sub CommandButton2_Click()
- End
- End Sub
複製代碼 |
|