select case ListBox.Text
 case "关机"
  '......
 case "重启"
  '......
end select程序老是判断不出来,每一个都不执行。

解决方案 »

  1.   

    ' 得先选中ListBox中的某一项Option ExplicitPrivate Sub Command1_Click()
    Select Case List1.Text
        Case "关机"
            Debug.Print "关机"
        Case "重启"
            Debug.Print "重启"
    End Select
    End SubPrivate Sub Form_Load()
    List1.AddItem "关机"
    List1.AddItem "重启"
    List1.ListIndex = 0
    End Sub
      

  2.   

    if keyascii = 13 then
     Select Case List1.Text
        Case "关机"
            Debug.Print "关机"
        Case "重启"
            Debug.Print "重启"
    End Select
    endif
    13 可以变成 any keyascii,此程序要在listbox的keyascii过程中写我认为应该好用
      

  3.   

    我的问题现在就是List1.Text这个值,也可以输出List1.Text,但就是不能用来比较,下面这样的语句也不能用。
    if List1.Text="关机" then
     '......
    end if一定要用下标的方式才行......
      

  4.   

    if List1.Text="关机" then
     '......
    end if可以比较