473,569 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String functions

I am new to VB, I need 2 string functions to return last char and remove
last char.
I made them up.
Am I recreating the wheel? do similar functions exist in String? I could not
find them

Public Class StringCode

Public Shared Function LastStringChar( ByVal str As String) As Char

If (str.Length > 0) Then

Return str.Chars(str.L ength - 1)

End If

Return ""

End Function

Public Shared Function RemoveLastStrin gChar(ByRef str As String) As String

If (str.Length > 0) Then

str = str.Remove(str. Length - 1, 1)

End If

Return str

End Function

End Class


Nov 21 '05 #1
1 1430
George,

You mean this one?
\\\
mystring = mystring.substr ing(0, mystring.lenght-1)
///

Cor

"George" <ge************ ********@hotmai l.com>
....
I am new to VB, I need 2 string functions to return last char and remove
last char.
I made them up.
Am I recreating the wheel? do similar functions exist in String? I could
not find them

Public Class StringCode

Public Shared Function LastStringChar( ByVal str As String) As Char

If (str.Length > 0) Then

Return str.Chars(str.L ength - 1)

End If

Return ""

End Function

Public Shared Function RemoveLastStrin gChar(ByRef str As String) As String

If (str.Length > 0) Then

str = str.Remove(str. Length - 1, 1)

End If

Return str

End Function

End Class

Nov 21 '05 #2

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

Similar topics

4
9079
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 how to add functionality to the string class. Rather than trying to inherit from the string class, the author was suggesting wrapping the string...
19
3174
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{ public: MyString(){} };
19
78777
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 find one.
2
3414
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 was splitted. I am fascinated to the powerfull use of this RegEx class, so I wonder if it could go a step further. As a question, can regex be...
8
4336
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 have done this as follows: LPOLESTR dunk_data = (LPOLESTR)T2CW(data_name);
29
4293
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 substring before a pattern), AFTER (return substring after a pattern), and BETWEEN (return substring between 2 patterns). My questions are: 1. Can...
6
7596
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, Karthi
3
1576
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 2.3.6) for more information on those. You should consider these functions as deprecated, although they will not be removed until Python 3.0. The...
14
10611
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? But I only get the first character. And when I try to do std::wstring l_s(convert(somestring)) I get really strange characters into l_s string...
15
1822
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 is not a lot of code, but obviously it is very important code that is used all over: VS2005: used in a C++/CLI module for .Net VS2005: Apache...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.