返回列表 上一主題 發帖

下拉式要如何選擇後會自動帶出其他表單訊息

回復  mark15jill


    感謝大大的協助
已經有找到我想要的寫法了(^口^)
Jared 發表於 2013-3-8 15:04



    小弟僅提示而已.. GBKEE大大才是高手

  多做多想多學習,少看少錯少迷途

  多做=多多練習,多多編寫。
  多想=想想為什麼人家程式要那樣寫,如果換成自己,又會怎寫。
  多學習=學習人家的發問並解答,學習人家的寫法

  少看=只看不做也枉然

TOP

回復 8# Jared
   
第一種寫法目前就是選擇完第一個ComboBox1
第二個選項會先呼應空白
只是想要讓他提前先顯示出來第一項

是這樣嗎?  1#表單的程式碼
  1. 'ListIndex = -1: 所選的不在 List清單內
  2. Dim 價格
  3. Private Sub ComboBox1_Change()
  4.     ComboBox2 = ""
  5.     TextBox1 = ""
  6.     If ComboBox1.ListIndex > -1 Then
  7.         ComboBox2 = ComboBox2.List(ComboBox1.ListIndex)
  8.         TextBox1 = 價格(ComboBox1.ListIndex)
  9.     End If
  10. End Sub
  11. '   Private Sub ComboBox2_Change()
  12. '       TextBox1 = ""
  13. '       If ComboBox2.ListIndex > -1 Then TextBox1 = 價格(ComboBox1.ListIndex)
  14. '   End Sub
  15. '****************************************************
  16. Private Sub CommandButton1_Click()
  17.     If ComboBox1.ListIndex = -1 Then MsgBox "餐點內容 需齊全 !!": Exit Sub
  18.     With Sheet10
  19.         .Cells(.Rows.Count, 1).End(xlUp).Offset(1).Resize(, 3).Value = Array(ComboBox1, ComboBox2, TextBox1)
  20.     End With
  21. End Sub
  22. Private Sub CommandButton2_Click()
  23.     test4.Hide
  24. End Sub
  25. Private Sub CommandButton3_Click()
  26.     ComboBox1 = ""
  27. End Sub
  28. Private Sub UserForm_Initialize()
  29.     With ComboBox1
  30.         .Font.Size = 12
  31.         .TextAlign = fmTextAlignCenter                  '文字置中
  32.         .List = Array("一號餐", "二號餐", "三號餐")
  33.     End With
  34.     With ComboBox2
  35.         .Font.Size = 12
  36.         .TextAlign = fmTextAlignCenter                  '文字置中
  37.         .List = Array("漢堡、薯條、可樂", "雞塊、薯餅、紅茶", "薯餅、薯條、冰淇淋")
  38.         .Locked = True                                  '禁止編輯
  39.     End With
  40.     With TextBox1
  41.         .Locked = True                                  '禁止編輯
  42.         .Font.Size = 12
  43.         .TextAlign = fmTextAlignCenter                   '文字置中
  44.     End With
  45.     價格 = Array(50, 60, 70)
  46. End Sub
複製代碼

TOP

回復 12# GBKEE


    感謝大大的解答
這就是我想要的方式
不過BoX2 這欄就不用鎖起來
才方便有另外兩種選擇~(^口^)
Jared

TOP

[版主管理留言]
  • GBKEE(2013/7/25 07:13): 要學習可附檔說明看看

這樣的選單,能否應用在班表班別上

TOP

        靜思自在 : 原諒別人就是善待自己。
返回列表 上一主題