- ©«¤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
        
|
¦^´_ 8# united7878
¸Õ¸Õ¬Ý- Option Explicit
- Dim Ar(), Sh As Worksheet, Msg As Boolean
- Dim C_Button()
- Private Sub UserForm_Initialize() 'ªí³æ¥¼Åã¥Ü«eªºªí³æµ{¦¡½X¨Æ¥ó
- Set Sh = Sheets("A") 'Database©Ò¦b¤u§@ªí
- '****************************************************************
- Ar = Array(myA, myB, myC, myD, myE, myF, myG, myH)
- 'Åã¥Ü¸ê®Æªº±±¨î¶µ¦¬¶°¨ì°}¦C¤¤
- C_Button = Array(SpinButton1, CommandButton1, CommandButton2, B2)
- '«ö¶sªº±±¨î¶µ¦¬¶°¨ì°}¦C¤¤
- '*****************************************************************
-
- myC.AddItem "¨k"
- myC.AddItem "¤k"
- Msg = True '¸ê®ÆŪ¨ú,¼g¤J¤¤
- With SpinButton1
- .Min = 2 '³Ì¤pÈ=²Ä2¦C¸¹
- .Max = Sh.Cells(Rows.Count, 1).End(xlUp).Row '³Ì¤jÈ
- If .Max = 1 Then '¨S¦³¸ê®Æ
- ±±¨î¶µ False '±±¨î¶µ¤£¥i¨Ï¥Î
- Else
- ¸ê®ÆŪ¨ú .Value '¦³¸ê®Æ:Ū¨ú¨ì±±¨î¶µ
- End If
- End With
- Msg = False
- End Sub
- Private Sub B1_Click() '·s¼W
- Dim i As Integer
- Msg = True '¸ê®ÆŪ¨ú,¼g¤J¤¤
- ±±¨î¶µ True '±±¨î¶µ¥i¨Ï¥Î
- With SpinButton1
- .Max = .Max + 1 '·s¼W:¼W¥[¤@¦C,³Ì¤jÈ + 1
- .Value = .Max 'Èn²¾¨ì³Ì¤jÈ
- Ar(0).Caption = Format(.Max - 1, "0000") '½s¸¹
- Sh.Cells(.Max, 1) = .Max - 1 '¸ê®Æ¤Wªº½s¸¹
- Sh.Cells(.Max, 1).NumberFormatLocal = "0000" '½s¸¹ªº®æ¦¡
- End With
- For i = 1 To 7
- Ar(i).Value = "" '²M°£±±¨î¶µªºÈ
- Next
- Msg = False
- End Sub
- Private Sub B2_Click() '²M°£
- Dim i As Integer
- Msg = True
- With SpinButton1
- For i = 0 To 7 '²M°£±±¨î¶µªºÈ
- If i = 0 Then
- Ar(i).Caption = ""
- Else
- Ar(i).Value = ""
- End If
- Next
- Sh.Cells(.Value, 1).Resize(, 8).Delete xlUp '§R°£¤u§@ªí¤W(.Value)¦C
- .Max = .Max - 1 '²M°£:´î¤Ö¤@¦C,³Ì¤jÈ - 1
- If .Value > .Max Then .Value = .Max '·í쥻È> ³Ì¤jÈ,È=³Ì¤jÈ
- If .Max = 1 Then '¨S¦³¸ê®Æ
- ±±¨î¶µ False '±±¨î¶µ¤£¥i¨Ï¥Î
- Else
- 'קï§R°£«áªº½s¸¹
- With Sh.Range(Sh.Range("A" & .Value), Sh.Range("A" & .Max))
- .Cells = "=ROW()-1" '¤u§@ªí¤W¦C¸¹-1
- .Value = .Value '¤½¦¡Âন´Ó
- .NumberFormatLocal = "0000" '½s¸¹ªº®æ¦¡
- End With
- Msg = False
- ¸ê®ÆŪ¨ú SpinButton1
- End If
- End With
- End Sub
- Private Sub CommandButton1_Click() '³Ì«á¤@µ§
- With SpinButton1
- .Value = .Max
- End With
- End Sub
- Private Sub CommandButton2_Click() '²Ä¤@µ§
- With SpinButton1
- .Value = .Min
- End With
- End Sub
- Private Sub myB_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub myC_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub myD_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub myE_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub myF_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub myG_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub myH_Change()
- If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
- End Sub
- Private Sub SpinButton1_Change() '«öÁ䦳²¾°Ê
- If Msg = False Then ¸ê®ÆŪ¨ú SpinButton1
- End Sub
- Private Sub SpinButton1_SpinDown() '«öÁä¦V¤U²¾°Ê
- With SpinButton1
- If .Value = .Min Then MsgBox "¤w¬O²Ä¤@µ§¸ê®Æ"
- End With
- End Sub
- Private Sub SpinButton1_SpinUp() '«öÁä¦V¤W²¾°Ê
- With SpinButton1
- If .Value = .Max Then MsgBox "¤w¬O²Ä³Ì«á¤@µ§¸ê®Æ"
- End With
- End Sub
- Private Sub ±±¨î¶µ(B As Boolean)
- Dim E As Variant
- For Each E In C_Button
- E.Enabled = B
- Next
- End Sub
- Private Sub ¸ê®ÆŪ¨ú(X As Long)
- Dim i As Integer
- Msg = True '¸ê®ÆŪ¨ú¤¤
- For i = 0 To 7
- If i = 0 Then
- Ar(i).Caption = Sh.Cells(X, 1).Text
- Else
- Ar(i).Value = Sh.Cells(X, i + 1)
- End If
- Next
- Msg = False '¸ê®Æ¤£¦bŪ¨ú¤¤
- End Sub
- Private Sub ¸ê®Æ¼g¤J(X As Long)
- Dim i As Integer
- Msg = True '¸ê®Æ¼g¤J¤¤
- For i = 0 To 7
- If i = 0 Then
- With Sh.Cells(X, 1)
- .Value = SpinButton1 - 1
- .NumberFormatLocal = "0000"
- End With
- Else
- Sh.Cells(X, i + 1) = Ar(i).Value
- End If
- Next
- Msg = False '¸ê®Æ¤£¦b¼g¤J¤¤
- End Sub
½Æ»s¥N½X |
|