Q:

PadRight(Int32, char) issues

I'm trying to create a 46 long ascii string/packet that gets sent out via serial.
The header is '###' followed by two 16 character ascii strings, then an 8 character acii string that represents a binary byte.
This is then completed with a 3 byte checksum.
Total length of 46 bytes.
My problem is two fold. 
First if the two 16 byte strings are full it adds a space after them.
Second, if the 16 byte text window isn't full I want to pad the remainder of the space with a space character.  This way the packet will all ways be a fixed length.
I'm attempting to use PadRight(Int32,char) but it doesn't add anything to the strings. What ends up happening is that when the code tries to add the checksum up it goes out of range because the packet is too small without the extra padding.
When I build it doesn't throw any errors but obviously I've done something wrong.
Here's the code snippet that isn't working.
TxPacket="###";
         TxText1=txtSerialTx1->Text;
         TxText2=txtSerialTx2->Text;

         TxText1=TxText1->Replace("\r\n","");  // stripping out CR and LF
         TxText2=TxText2->Replace("\r\n","");

         if((TxText1->Length) < 16)           // Checking for valid length
            {
                TxText1->PadRight((16-(TxText1->Length)),'S');
            }
         if((TxText2->Length) < 16)
            {
                TxText2->PadRight((16-(TxText2->Length)),'S');
            }

         TxPacket="###"+ TxText1 + TxText2 + TxLed;

    for(int i=3;i<40;i++)
        {
            iChecksum+= TxPacket[i];
        }

    TxPacket+=(iChecksum%1000);

         serialPort1->Write(TxPacket);

A:

Found my issue after playing some more with it.  I didn't realize that the length of the padding was a fixed value and that C++ will calculate the number of spaces to insert for me so I was working out the offset manually.
Also noticed that I didn't assign the end result back to the string.  MSDN had an example that was being done inline with the code so they didn't re-assign the value back.  

