简体   繁体   中英

How to use Case in a VB Macros combo box?

I'm constructing a macro form, and I have this code

Private Sub UserForm_Initialize()
    ComboBox1.List = Array("Tipo A", "Tipo B", "Tipo C")
End Sub

I want to know how to use a case from this code.

If you're trying to use a Select Case , you can simple do it like this:

Select Case ComboBox1
Case "Tipo A"
    ' what you want to do for Tipo A
Case "Tipo B"
    ' and another for Tipo B
Case "Tipo C"
    ' for Tipo C
Case Else
    ' what you want to do otherwise
End Select

You can add this in to what ever Form Control Event you want to use. Take note that you can only evaluate the ComboBox1 at runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM