Thread: String Replace Function

  1. #16
    Registered User
    Join Date
    Mar 2009
    Quote Originally Posted by tabstop View Post
    That's maximum unsigned int, surely?
    Yes, I should have said uint, which is what should be used for counting characters since you would never have less than 0 characters.

  2. #17
    Registered User
    Join Date
    May 2009
    Well guys I was thinking of a short when I said 32k max lol...

    Well the rtbox.Lines array is only read only, so I'm afraid the copy won't work. I'm looking for other methods of getting only the contents I need from one rtbox to another using builtin functions if at all possible. While I could do a loop this would be unacceptable as the amount of data could be large.

  3. #18
    Registered User
    Join Date
    May 2009
    Ok everyone, the answers been in the function I was trying to use. Just not going about it the correct way. Heres what appears to be a working solution:

    Dim lines(CInt(TextBox2.Text)) As String
    Array.ConstrainedCopy(RichTextBox1.Lines, CInt(TextBox1.Text), lines, 0, CInt(TextBox2.Text))
    RichTextBox2.Lines = lines

    I'd translate it to C# but it should pretty much be the same. Don't know if C# gives you access to Array.ConstrainedCopy. Whats going on? Well this is just a test project. I got two RichTextBoxes and the object was to copy from line x (TextBox1) y (TextBox2) number of lines to RichTextBox B from RichTextBox A. I tried taking advantage of ReDim Preserve functionality in VB orginally, but that didnt work so declaring the lines array to store the end result with the correct size off the bat is a must. No pretty one liners but its working.


    Here's what a C# version might look like to satisify the forum this topic was posted in:

    String[TextBox2.Text] lines;
    Array.ConstrainedCopy(RichTextBox1.Lines, (int)TextBox1.Text, lines, 0, (int)TextBox2.Text);
    RichTextBox2.Lines = lines;
    Last edited by kairozamorro; 08-28-2009 at 06:54 PM. Reason: Included C# code

  4. #19
    Registered User
    Join Date
    May 2009
    Ok, implemented into the actual program now and its working. Thanks to everyone who helped

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Using the string replace function
    By FoodDude in forum C++ Programming
    Replies: 7
    Last Post: 09-23-2005, 02:31 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM