473,385 Members | 1,409 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,385 software developers and data experts.

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.Length - 1)

End If

Return ""

End Function

Public Shared Function RemoveLastStringChar(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 1414
George,

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

Cor

"George" <ge********************@hotmail.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.Length - 1)

End If

Return ""

End Function

Public Shared Function RemoveLastStringChar(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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.