2011-12-23 54 views
2

は "UngültigerBezeichner"(無効identifiert)を報告します。それが文句を言う行はSelect Case parts.Lengthです。それはpartsについて不平を言っている。何か案は? VBAの配列の長さを決定するために無効な識別子

Public Sub parseFileName(fName As String, ByRef art As String, ByRef objnr As String, ByRef phase As String, ByRef index As String, ByRef text As String, ByRef warning As Boolean) 
    Dim parts() As String 

    parts = Split(fName, ".") 
    parts = Split(fName, parts(0)) 

    warning = False 
    Select Case parts.Length 
     Case Is < 5 ' not a valid filename, do nohting 
      Return 
     Case 5 ' old style file name 
      art = part(0) 
      objnr = part(1) 
      text = part(2) 
      index = part(4) 
     Case 6 ' new stype file name 
      art = part(0) 
      phase = part(1) 
      objnr = part(2) 
      text = part(3) 
      index = part(5) 
     Case Is > 6 ' user used _ in text, do what we can and issue warning 
      art = part(0) 
      phase = part(1) 
      objnr = part(2) 
      text = part(3) 
      index = part(5) 
      warning = True 
    End Select 
End Sub 

答えて

3

Dim arrLength as Integer 

arrLength = UBound(parts) - LBound(parts) + 1