473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

String Functions

What string function will cut off the last 3 characters from a string?

For example: if I had the string,

dim strtext as string = testcalls
I want to only return the strtext as test and take off the calls.
Apr 1 '08 #1
3 1458
On Apr 1, 5:37 pm, cmdolcet69 <colin_dolce...@hotmail.comwrote:
What string function will cut off the last 3 characters from a string?

For example: if I had the string,

dim strtext as string = testcalls

I want to only return the strtext as test and take off the calls.
Substring function.

Your example is not well-formed but i guess it's:
Dim strtext As String = "testcalls"

To display only "test" chars from whole "testcalls" word;

Substring(0,4)

which defines 0 is startIndex point and 4 is the length that belongs
the length of "test".
Apr 1 '08 #2
On Apr 1, 10:51*am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Apr 1, 5:37 pm, cmdolcet69 <colin_dolce...@hotmail.comwrote:
What string function will cut off the last 3 characters from a string?
For example: if I had the string,
dim strtext as string = testcalls
I want to only return the strtext as test and take off the calls.

Substring function.

Your example is not well-formed but i guess it's:
Dim strtext As String = "testcalls"

To display only "test" chars from whole "testcalls" word;

Substring(0,4)

which defines 0 is startIndex point and 4 is the length that belongs
the length of "test".

What happends if i dont know the lenght. Because the lenght may change.
Apr 1 '08 #3
On Tue, 1 Apr 2008 08:02:04 -0700 (PDT), cmdolcet69
<co************@hotmail.comwrote:
>On Apr 1, 10:51*am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
>On Apr 1, 5:37 pm, cmdolcet69 <colin_dolce...@hotmail.comwrote:
What string function will cut off the last 3 characters from a string?
For example: if I had the string,
dim strtext as string = testcalls
I want to only return the strtext as test and take off the calls.

Substring function.

Your example is not well-formed but i guess it's:
Dim strtext As String = "testcalls"

To display only "test" chars from whole "testcalls" word;

Substring(0,4)

which defines 0 is startIndex point and 4 is the length that belongs
the length of "test".


What happends if i dont know the lenght. Because the lenght may change.
Dim strtext As String = "testcalls"

strtext = strtext.Substring(0, strtext.Length - 3)

But I think you really want 5 instead of 3 since "calls" is 5
characters long, not 3.

or:
strtext = strtext.Substring(0, strtext.Length - "calls".Length)

or
strtext = strtext.Remove(strtext.Length - "calls".Length)
Apr 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Carl Youngblood | last post by:
I imagine this subject has probably been brought up numerous times. Forgive me for bringing it up again. I was googling through old posts on this newsgroup about it and found a good suggestion on...
19
by: Mike Tyka | last post by:
Hello community, i'm fairly new to using the STL but i've been experimenting a bit with it. I tried to derive a new class say MyString from string like so: class MyString: public string{...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
2
by: Tim Conner | last post by:
Hi, Thanks to Peter, Chris and Steven who answered my previous answer about regex to split a string. Actually, it was as easy as create a regex with the pattern "/*-+()," and most of my string...
8
by: Duncan Winn | last post by:
I am new to VC++7. I am using a method GetPrivateProfileString that requires an LPTSTR. I have defined this as a: char * data_name; I am then trying to convert this to an LPOLESTR and I...
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
3
by: Hitesh | last post by:
Hi, In python doc -- 4.1.4 Deprecated string functions -- I read that "The following list of functions are also defined as methods of string and Unicode objects; see ``String Methods'' (section...
14
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have seen the following function to convert from a System::String^ to a const wchar_t*. I would like to get a LPCTSTR and AFAIK LPCTSTR is equal to const wchar_t*. Then it should all work right?...
15
by: Cartoper | last post by:
There is one little static C library to manage the serial number and unlock key for my application. Today it is compiled with Microsoft VC6 and linked into both VC6 modules and VS2005 modules. It...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.