Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cut off first letter of a string

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I have a string that is passed to my server app from my client app. The string is like this:

1123

It is a max of four numbers. The first number I am using to tell the server app what com port to use. If the first number is 1, then I'll use com port 1 etc.

The last three numbers are the TV channel.

If I want channel 007, on com port 2, then the string will be "27".

How can I chop off the first digit and then keep the last part of the string intact?

Thanks.

Mindy
 
Look at your other thread for my posting to use SubString. Alternately, you can use the archaic square brackets.
Code:
// String TheCode is set up somewhere else

int TheLen = ComPort.Length(); // String Length
if (TheLen > 0)
{

    // If the length is 0, don't do this
    String ComPort = TheCode[1]; // Notice AnsiStrings use 1 for first place

    String Channel = TheCode.SubString(2, TheLen); // The rest of the string
}

Again, this off the top of my head so you may have to play with the code a bit. Also C++ strings have similar functions.
James P. Cottingham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top