2013-02-17 7 views
2

在我的SSIS包中使用的腳本下方。如何使用多個分隔符分割字符串

If (Row.AnswerType.Trim().ToUpper = "MULTIPLE SELECT" And _ 
    Row.SurveyQuestionID = Row.SurveyDefinitionDetailQuestionNumber) Then 

    Dim Question1 As String = Row.SurveyDefinitionDetailAnswerChoices.ToUpper.Trim() 
    Dim ans1 As String = Row.SurveyAnswer.ToUpper.Trim() 

    For Each x As String In ans1.Split(New [Char]() {CChar(vbTab)}) 
     If Question1.Contains(x) Then 
      Row.IsSkipped = False 
     Else 
      Row.IsSkipped = True 
      'Row.IsAllowed = True 
      Row.ErrorDesc = "Invalid Value in Answer Column For Multiple Select!" 
     End If 
    Next 
End If 

此腳本僅在使用製表符作爲分隔符時纔會成功。但我需要製表符和非製表符作爲分隔符。

回答

6

使用字符文字後綴C

ans1.Split(New [Char]() { CChar(vbTab), CChar(" "), CChar(";") }) 

或者

ans1.Split(New [Char]() { CChar(vbTab), " "C, ";"C }) 

所有需要的字符添加到字符數組。

+0

非常感謝Olivier – Dinesh 2013-02-17 16:25:31

相關問題