2016-09-09 16 views

答えて

1

私はあなたのイメージを見ることはできませんが、あなたの説明の後、次の機能を探しています:それを使用する方法の

Function Remove_last_part(StrCommaSeparated As String) As String 

    Dim arr() As String 
    Dim i As Integer 

    arr = Split(StrCommaSeparated, ",") ' make an array out of the comma separated string 

    ReDim Preserve arr(UBound(arr) - 1) ' Remove the last array element, by redimensioning the array to it's total elements minus 1 

    Remove_last_part = Join(arr, ",") ' make a comma separated string out of the redimensionned array 

End Function 

例:

Public Sub TestIt() 

    Dim strTest As String 

    strTest = "anything,anywhen,anyhow,New York" 

    Debug.Print "BEFORE -->" & strTest 
    Debug.Print "AFTER -->" & Remove_last_part(strTest) 

End Sub 

ウィル出力:

BEFORE -->anything,anywhen,anyhow,New York 
AFTER -->anything,anywhen,anyhow 
+0

ありがとうございました!私のやや基本的な質問に対する謝罪! –

関連する問題