现有字符串\\user21\hp101,一个网络打印机的路径,如何取出前面的机器名user21,如何取出hp101

解决方案 »

  1.   

    Dim strA As String
    Dim i As Long
    strA = "\\user21\hp101"
    i = InStr(3, strA, "\")
    MsgBox Mid(strA, 3, i - 3)
    MsgBox Right(strA, Len(strA) - i)
      

  2.   

    用left,right函授都可以,加上判斷的“\\”"\"就可以了阿。這麽簡單還問阿。什麽東西都問得話,放你頭上那東西幹嗎用呢?嘿
      

  3.   

    s="\\user21\hp101"
    x=instr(s,"\\")
    y=instr(x+2,s,"\")
    s1=mid(s,x+2,y-x-2)s1就是所求内容
      

  4.   

    使用Split(expression[, delimiter[, count[, compare]]])函数最方便
    dim aa as Variant
    bb="\\user21\hp101"
    aa=split(bb,"\")
    aa(3)就是你所要的