SOS

在一个VB程序中,有一个combo1和lable1的两个控件,combo1的下拉内容是abc:123,当下拉里选中abc:123项时,让lable1.text显示123,这个语句该怎么写?虾米求教

解决方案 »

  1.   

    Private Sub Combo1_Click()
        Label1.Caption = Right(Combo1.Text, 3)
    End SubPrivate Sub Form_Load()
        Combo1.AddItem "abc:123"
        Combo1.AddItem "abc:124"
    End Sub
      

  2.   

    Private Sub Combo1_Click()
        Dim a() As String
        a = Split(Combo1.Text, ":")
        If UBound(a) >= 1 Then
            Label1 = a(1)
        End If
    End Sub
      

  3.   


    Private Sub Combo1_Click()dim StrA as string
    StrA =split(Combo1.Text,":")(1)
    Label1.Caption = StrA 
    End Sub
      

  4.   


    测试通过   -.-
    可 这句不太理解 Label1 = a(1) 
    等同 Label1.Caption = a(1)   ? 
     
      

  5.   

    肯定是Label1.Caption呀,截取字符串即可。方法很多的
      

  6.   

    Private Sub Combo1_Click()
       Dim S
       If Combo1.Text = "abc:123" Then '如果选中项的内容等于"abc:123"
          S = Split(Combo1.Text, ":") '将选中的内容以冒号分割,导入变体型变量
          If UBound(S) >= 1 Then Label1.Caption = S(1) '>=1表示变量中确保含有分隔符冒号
       End If
    End Sub
      

  7.   

    Label 控件的默认属性是 Caption,所以可以省略。
      

  8.   


    Private Sub Combo1_Click()
        Label1.Caption = Split(Combo1.Text, ":")(1)
    End SubPrivate Sub Form_Load()
        Combo1.AddItem "abc:123"
        Combo1.AddItem "abc:124"
    End Sub