Is that a specific example of a more general case?. For example, if the last three fields are always -1,-1,-1 then you just need to replace ",-1,-1,-1)" with ")". However, if the last three fields can take on other values then one solution would be a loop that would look for the last "," and strip off the last field. You could do (for example):
Private Function StripLast(ByVal flds As String, ByVal numflds As Integer) As String
Do While numflds > 0
flds = flds.Substring(0, flds.LastIndexOf(","))
numflds -= 1
Loop
Return flds & ")"
End Function
will return the string with the last given number of fields stripped off. Sample call is:
flds = "YYYYYYYYYYYYYYYYYYY.',Y,'YYYYY YY YYYY YYY YYYY XX.XX',X,X,-1,-1,-1)"
flds = StripLast(flds,3)
'flds now has the value "YYYYYYYYYYYYYYYYYYY.',Y,'YYYYY YY YYYY YYY YYYY XX.XX',X,X)"
Is this what you intended?