flynn Posted March 2, 2006 Posted March 2, 2006 (edited) I know the following code doesn't work (.Chars is read-only), but hopefully you'll understand what I am wanting to do: I want to cycle through sBuffer to remove certain QUOTE characters that are contained within certain phrases. Is there a method that is writable that I can copy the valid characters into? Something similar to the .Chars method, but also writable. While iOldIndx < iFileLength If (sBuffer.Chars(iOldIndx) <> """") Then 'keep this character by copying to the new buffer sNewBuf.Chars(iNewIndx) = sBuffer.Chars(iOldIndx) iNewIndx += 1 End If iOldIndx += 1 End While tia, flynn Edited March 2, 2006 by flynn Quote
flynn Posted March 2, 2006 Author Posted March 2, 2006 I think maybe the answer to my question is to use a StringBuilder. The .Chars method is read/write. Quote
Cags Posted March 2, 2006 Posted March 2, 2006 You could simply amend the new char to the end of a string for example Dim sNewString as String = "" While iOldIndx < iFileLength If (sBuffer.Chars(iOldIndx) <> """") Then 'keep this character by copying to the new buffer sNewString += sBuffer.Chars(iOldIndx) End If iOldIndx += 1 End While however if your buffer is over a few chars long (which i'm assuming it will always be), then you should do as you say and use the string builder. Quote Anybody looking for a graduate programmer (Midlands, England)?
Leaders snarfblam Posted March 2, 2006 Leaders Posted March 2, 2006 You could also create a Char array. The string class has a ToChars function which returns the string in the form of a Char array, and a char array can be cast to a string (at least in VB). A Char array will have less overhead, but the StringBuilder is probably easier. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.