2015年8月17日 星期一

0817 note

form optionbutton
 Private Sub CommandButton1_Click()
    Dim s As String
 
    If OptionButton1.Value = True Then
        s = OptionButton1.Caption
    ElseIf OptionButton2.Value = True Then
        s = OptionButton2.Caption
    ElseIf OptionButton3.Value = True Then
        s = OptionButton3.Caption
    End If
'    Dim i As Integer
'
'    For i = 1 To 3
'        If Me.Controls("OPTIONbutton" & i).Value = True Then
'            s = Me.Controls("OPTIONbutton" & i).Caption
'            Exit For
'        End If
'    Next i
 
    MsgBox s
End Sub

Private Sub CommandButton2_Click()
    OptionButton1.Value = False
    OptionButton2.Value = False
    OptionButton3.Value = False
End Sub

Private Sub UserForm_Click()

End Sub

=============================================
form chectbox
1.checkbox1.value=boolean
   true
  false
2.checkbox1.caption="string"
 顯示值
3checkbox1.Autosize=boolean
自動依文字調整大小
=====================

Private Sub CommandButton1_Click()
    Dim plist As Integer
    Dim i As Integer
    Dim result As String
 
    plist = ListBox1.ListCount
    For i = 1 To plist
        If ListBox1.Selected(i - 1) = True Then
            result = result + ListBox1.List(i - 1)
        End If
    Next i
 
    MsgBox result
End Sub

Private Sub CommandButton2_Click()
    Dim plist As Integer
    Dim i As Integer
 
    plist = ListBox1.ListCount
    For i = 1 To plist
        ListBox1.Selected(i - 1) = False
    Next i
End Sub

Private Sub UserForm_Activate()
    ListBox1.AddItem "百合花"
    ListBox1.AddItem "玫瑰花"
    ListBox1.AddItem "金針花"
    ListBox1.AddItem "杜鵑花"
    ListBox1.AddItem "水仙花"
    ListBox1.MultiSelect = fmMultiSelectMulti
End Sub
======================
Private Sub ScrollBar1_Change()
    TextBox1.Value = ScrollBar1.Value
End Sub



Private Sub UserForm_Click()
    TextBox1.Value = 0
End Sub
==================================
Private Sub SpinButton1_Change()
    TextBox1.Value = SpinButton1.Value
End Sub



Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
 TextBox1.Value = 0
End Sub
====================

沒有留言:

張貼留言