/
微調按鈕與文字方塊連動
54 lines (45 loc) · 1.03 KB
/
微調按鈕與文字方塊連動
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Private Sub UserForm_Initialize()
With Me.SpinButton1
.Max = 20
.Min = 1
.SmallChange = 1
.Value = 19
End With
Me.TextBox1.TextAlign = fmTextAlignCenter
End Sub
Private Sub SpinButton1_Change()
TextBox1.Value = SpinButton1.Value
End Sub
'*************************************************
'微調按鈕,當到達最大值時,反向變回最小值(但原理還不是很懂Orz)
Dim mySpn As Boolean
Private Sub UserForm_Initialize()
With Me.SpinButton1
.Max = 20
.Min = 1
.SmallChange = 1
.Value = 15
End With
Me.TextBox1.TextAlign = fmTextAlignCenter
End Sub
Private Sub SpinButton1_Change()
mySpn = True
TextBox1.Value = SpinButton1.Value
mySpn = SpinButton1.Value
End Sub
Private Sub SpinButton1_SpinDown()
With SpinButton1
If mySpn = False Then
If .Value = .Min Then .Value = .Max
End If
mySpn = False
End With
End Sub
Private Sub SpinButton1_SpinUp()
With SpinButton1
If mySpn = False Then
If .Value = .Max Then .Value = .Min
End If
mySpn = False
End With
End Sub