VBA在两个斜线之间剪切字符串

时间:2014-01-27 05:43:59

标签: excel vba

我是VBA nwebie。我想在两个斜线之间剪切String。这是我的字符串

    /branches/test

我希望获得以下输出

     branches

我该如何定义它?

2 个答案:

答案 0 :(得分:1)

您可以按Split功能继续;

Dim s as string = "/branches/test"
Dim sArray() As String
Dim result As String

sArray = Split(s, "/") 
result = sArray(1)

答案 1 :(得分:0)

这正是我需要的

    Dim x As Variant
    Dim i As Long

    x = Split("/branches/test", "/")
    For i = 1 To UBound(x)
        Debug.Print x(i)
    Next i

输出是

      branches
      test