- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-6-22 05:00 ½s¿è
¦^´_ 3# bsy4life
¶¶«K½Ð±Ð¤@¤UcomboboxµLªk¥Î·Æ¹«ºu°Ê¬On«ç»ò§ï
¤£¬O¦³¤è¦VÁä¥i¥Î
work ªí³æ¼Ò²Õµ{¦¡½X¸Õ¸Õ¬Ý
TextBoxProductNumber,TextBoxMachineNumber,ComboBoxProcess
¬Ò§ï¬° ComboBox ªº±±¨î¶µ ¨ä BoundColumn ÄÝ©Ê ½Ð«ü©w=1- Dim d As Object, Msg As Boolean '³oªí³æ¼Ò²Õ ªº¨p¥ÎÅܼÆ
- Private Sub UserForm_Initialize()
- TextBoxWorkOrderNumber = New_TextBoxWorkOrderNumber
- TextBoxProductNumber_MakeList
- TextBoxMachineNumber_MakeList
- Msg = True
- End Sub
- Private Sub TextBoxProductNumber_Change()
- With ComboBoxProcess ' »sµ{ ±±¨î¶µ
- .Clear
- If TextBoxProductNumber.ListIndex > -1 Then
- If d(TextBoxProductNumber.Value).Rows.Count = 1 Then
- .AddItem d(TextBoxProductNumber.Value).Cells(2) '®Æ¸¹¥u¦³¤@Ó
- Else
- .List = d(TextBoxProductNumber.Value).Columns(2).Value '¬Û¦P®Æ¸¹ ¤£¥u¤@Ó ªº»sµ{½d³ò
- End If
- .ListIndex = 0
- End If
- End With
- xChicked
- End Sub
- Private Sub ComboBoxProcess_Change()
- LabeExceptTimeShow.Caption = ""
- LabelProcessTimeShow.Caption = ""
- With ComboBoxProcess
- If .ListIndex > -1 Then
- ' *** d(TextBoxProductNumber.Value) ->Range ª«¥ó***
- LabeExceptTimeShow.Caption = d(TextBoxProductNumber.Value).Cells(.ListIndex + 1, "C")
- LabelProcessTimeShow.Caption = d(TextBoxProductNumber.Value).Cells(.ListIndex + 1, "D")
- End If
- End With
- xChicked
- End Sub
- Private Sub TextBoxMachineNumber_Change() '±a¤J¾÷¾¹«¬¸¹ªº¸ê®Æ
- With TextBoxMachineNumber
- LabelMachineShow.Caption = ""
- If .ListIndex > -1 Then LabelMachineShow.Caption = .List(.ListIndex, 1)
- End With
- xChicked
- End Sub
- Private Sub TextBoxWorkOrderNumber_Change()
- xChicked
- End Sub
- Private Sub CommandButtonSend_Click()
- Dim Rng As Range, BtnCode As Integer
- If MsgBox("·s¼W¬£¤u - " & TextBoxWorkOrderNumber, vbYesNo + 16 * 2, "¸ê®Æ°e¥X") = vbNo Then Exit Sub
- With Sheets("·s¼W¬£¤u")
- Set Rng = .Range("A1").End(xlDown)
- If Rng.Row = Rows.Count Then Set Rng = .Range("A1")
- End With
- With Rng.Offset(1)
- .Cells(1, 1) = TextBoxWorkOrderNumber.Value '¤u³æ½s¸¹
- .Cells(1, 2) = TextBoxProductNumber.Value '®Æ¸¹
- .Cells(1, 3) = ComboBoxProcess.Text '»sµ{
- .Cells(1, 4) = TextBoxMachineNumber.Value '¾÷¾¹½s¸¹
- .Cells(1, 5) = LabelMachineShow.Caption '¾÷¾¹«¬¸¹
- .Cells(1, 6) = LabeExceptTimeShow.Caption '°£¥~¤u®É
- .Cells(1, 7) = LabelProcessTimeShow.Caption '³æ¦¸¤u®É
- End With
- TextBoxProductNumber.ListIndex = -1
- TextBoxMachineNumber.ListIndex = -1
- ComboBoxProcess.ListIndex = -1
- BtnCode = CreateObject("WScript.Shell").popup("¦¹Àɮפw¦Û°Ê¦sÀÉ", 1, Caption)
- ThisWorkbook.Save
- TextBoxWorkOrderNumber = New_TextBoxWorkOrderNumber
- BtnCode = CreateObject("WScript.Shell").popup("¤u³æ½s¸¹ " & TextBoxWorkOrderNumber, 2, Caption)
- TextBoxWorkOrderNumber.SetFocus
- End Sub
- Private Sub CommandButtonExit_Click()
- End
- End Sub
- Private Sub TextBoxProductNumber_MakeList() '»sµ{¤u®É:®Æ¸¹¸ê®Æ
- Dim Rng As Range
- Set d = CreateObject("scripting.dictionary") '¦r¨åª«¥ó
- Set Rng = Sheets("»sµ{¤u®É").Range("A2")
- Do While Rng <> ""
- If d.EXISTS(Rng.Value) Then
- Set d(Rng.Value) = Union(Rng.Resize(, 4), d(Rng.Value)) '®Æ¸¹, »sµ{, °£¥~¤u®É,³æ¦¸¤u®É
- Else
- Set d(Rng.Value) = Rng.Resize(, 4) '®Æ¸¹, »sµ{, °£¥~¤u®É,³æ¦¸¤u®É
- End If
- Set Rng = Rng.Offset(1)
- Loop
- With TextBoxProductNumber
- .List = d.KEYS
- .ListIndex = 0
- End With
- End Sub
- Private Sub TextBoxMachineNumber_MakeList() 'List ¥]§t( ¾÷¾¹½s¸¹ , «¬¸¹)
- With Sheets("¾÷¾¹«¬¸¹")
- TextBoxMachineNumber.List = .Range("A2:B" & .Range("A1").End(xlDown).Row).Value
- End With
- TextBoxMachineNumber.ListIndex = 0
- End Sub
- Private Function New_TextBoxWorkOrderNumber() As String '·s¼W ¤u³æ¸¹½X ®æ¦¡: XXX-1234567890
- Dim New_No As Variant
- With Sheets("·s¼W¬£¤u").Range("A1").End(xlDown)
- If .Row > 1 And .Cells <> "" Then
- New_No = Split(.Cells, "-")
- New_No(1) = Format(Val(New_No(1)) + 1, "0000000000")
- New_TextBoxWorkOrderNumber = New_No(0) & "-" & New_No(1)
- End If
- End With
- End Function
- Private Sub xChicked() '¨¾§bµ{¦¡
- Dim BtnCode As Integer, xOrder, Msg As Boolean
- With CommandButtonSend
- .Enabled = TextBoxProductNumber.ListIndex > -1 And ComboBoxProcess.ListIndex > -1 And TextBoxMachineNumber.ListIndex > -1
- .Enabled = .Enabled And Len(Trim(TextBoxWorkOrderNumber)) = 14
- If Len(Trim(TextBoxWorkOrderNumber)) = 14 Then
- xOrder = Split(TextBoxWorkOrderNumber, "-")
- If UBound(xOrder) = 0 Then Msg = True
- If UBound(xOrder) = 1 Then
- If Len(xOrder(0)) <> 3 Then Msg = True '«e¤T½X
- If Len(xOrder(1)) <> 10 Then Msg = True '«á¤Q½X
- If Len(xOrder(1)) = 10 And IsNumeric(xOrder(1)) = False Then Msg = True '«á¤Q½X»Ý¬°¼Æ¦r
- End If
- If Msg Then BtnCode = CreateObject("WScript.Shell").popup("¤u³æ½s¸¹ ¿ù»~ " & TextBoxWorkOrderNumber & vbLf & "¦p :xxx-1234567890", 2, Caption)
- .Enabled = .Enabled And Msg = False
- End If
- End With
- End Sub
½Æ»s¥N½X |
|