ConnectString={Persist Security Info=True;Provider=SQLOLEDB.1;User ID=sa;Password=sa;Data Source=JINDEEE;Initial Catalog=AIS20080807081820};UserName=祝浩文;UserID=16409;DBMS Name=Microsoft SQL Server;DBMS Version=2000/2005;SubID=k3bos#List|220000004;AcctType=gy;Setuptype=Industry;Language=chs;IP=198.162.100.121;MachineName=ZJB2;UUID=DB07D920-3E2B-4B82-98E2-5339528225FF
以上字符串,我要得到UserID = 16409中的值 16409,谢谢了.

解决方案 »

  1.   

    Private Sub Form_Load()
    Dim str As String, a As Variant
    Dim i As Integer
    str = "ConnectString={Persist Security Info=True;Provider=SQLOLEDB.1;User ID=sa;Password=sa;Data Source=JINDEEE;" & _
        "Initial Catalog=AIS20080807081820};UserName=祝浩文;UserID=16409;DBMS Name=Microsoft SQL Server;DBMS Version=2000/2005;" & _
        "SubID=k3bos#List|220000004;AcctType=gy;Setuptype=Industry;Language=chs;IP=198.162.100.121;MachineName=ZJB2;UUID=DB07D920-3E2B-4B82-98E2-5339528225FF"
        a = Split(str, ";")
        For i = LBound(a) To UBound(a)
            If Left(a(i), 6) = "UserID" Then
                MsgBox Right(a(i), 5)
                Exit For
            End If
        Next i
    End Sub
      

  2.   

    a = val(Split(str, "UserID=")(1))
      

  3.   

    Private Sub Command1_Click()
    Dim str As String, a As Variant
    Dim i As Integer
    str = "ConnectString={Persist Security Info=True;Provider=SQLOLEDB.1;User ID=sa;Password=sa;Data Source=JINDEEE;" & _
    "Initial Catalog=AIS20080807081820};UserName=祝浩文;UserID=16409;DBMS Name=Microsoft SQL Server;DBMS Version=2000/2005;" & _
    "SubID=k3bos#List|220000004;AcctType=gy;Setuptype=Industry;Language=chs;IP=198.162.100.121;MachineName=ZJB2;UUID=DB07D920-3E2B-4B82-98E2-5339528225FF"
        a = Val(Split(str, "UserID=")(1))
        Print a
    End Sub