Hi,
Using C#, what is the equivalent of functions Left, Right and Mid that we
had in vb6?
Thanks,
Alan 8 38601
left is MyString.SubString(0,length)
mid is MyString.SubString(start, length)
right is MyString.SubString(MyString.Length - length)
--
Michael Culley
"A.M" <IH*******@sapm123.com> wrote in message news:uM**************@TK2MSFTNGP09.phx.gbl... Hi,
Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6?
Thanks, Alan
string myString = "My String";
Left: myString.Substring(0, 4); // Left 4 characters
Right: myString.Substring(myString.Length - 4); // Right 4 characters
Mid: myString.Substring(startIndex); // Mid overload 1
Mid: myString.Substring(startIndex, count); // Mid overload 2
Mid has optional parameters, so these act as overloads in C#. The Substring
method can easily handle all formats of the VB methods. You will have to
convert
from using 1 based indexing to 0 based indexing, since the VB functions use 1 to
denote the first character and Substring uses 0.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"A.M" <IH*******@sapm123.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl... Hi,
Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6?
Thanks, Alan
as well as the answers the other guys have provided, you can also import the
visualbasic lib and actually use left, right and mid in c'
--
Regards
John Timney
Microsoft Regional Director
Microsoft MVP
"A.M" <IH*******@sapm123.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl... Hi,
Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6?
Thanks, Alan
Thaks John, That is actually a good idea!
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:uA*************@tk2msftngp13.phx.gbl... as well as the answers the other guys have provided, you can also import
the visualbasic lib and actually use left, right and mid in c'
-- Regards
John Timney Microsoft Regional Director Microsoft MVP
"A.M" <IH*******@sapm123.com> wrote in message news:uM**************@TK2MSFTNGP09.phx.gbl... Hi,
Using C#, what is the equivalent of functions Left, Right and Mid that
we had in vb6?
Thanks, Alan
A.M <IH*******@sapm123.com> wrote: Thaks John, That is actually a good idea!
No, it's not. Substring is a perfectly good alternative, and one which
stays within the idiom of C# and .NET, rather than making your code
look like a mixture of C# and old VB.
It will work, but it will be harder for other C# programmers (without
VB experience) to understand. It will require the Microsoft.VisualBasic
assembly to be loaded for no particularly good reason. It will use a
method which has been significantly less thoroughly tested than
Substring (because virtually all .NET programmers use Substring whereas
only a few will be using the ported VB methods).
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
"A.M" <IH*******@sapm123.com> wrote in news:uMMhrMSPEHA.1392
@TK2MSFTNGP09.phx.gbl: Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6?
Remember that in .NET strings are objects. So dont look for global functions,
but look at the methods of the string object itself.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Get your ASP.NET in gear with IntraWeb! http://www.atozed.com/IntraWeb/
I couldn't agree more. Just because something can be done
is not a logical reason for doing so.
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... A.M <IH*******@sapm123.com> wrote: Thaks John, That is actually a good idea! No, it's not. Substring is a perfectly good alternative, and one which stays within the idiom of C# and .NET, rather than making your code look like a mixture of C# and old VB.
It will work, but it will be harder for other C# programmers (without VB experience) to understand. It will require the
Microsoft.VisualBasic assembly to be loaded for no particularly good reason. It will use a method which has been significantly less thoroughly tested than Substring (because virtually all .NET programmers use Substring
whereas only a few will be using the ported VB methods).
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Thank you for comment.
Unfotunately, I have to be 100% agree with you about about using
Microsoft.VisualBasic assmebly; however I have to subclass my own simple
string class to abstract Left and Mid and Right. It is not the name of
function. It is more convenient to send a simple parameter which is really
needed for that operation if we use it too often.
I was excited because I didn't think about using Microsoft.VisualBasic
assmebly in C# !
Thank you again,
Alan
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... A.M <IH*******@sapm123.com> wrote: Thaks John, That is actually a good idea!
No, it's not. Substring is a perfectly good alternative, and one which stays within the idiom of C# and .NET, rather than making your code look like a mixture of C# and old VB.
It will work, but it will be harder for other C# programmers (without VB experience) to understand. It will require the Microsoft.VisualBasic assembly to be loaded for no particularly good reason. It will use a method which has been significantly less thoroughly tested than Substring (because virtually all .NET programmers use Substring whereas only a few will be using the ported VB methods).
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mitsura |
last post by:
Hi,
I have included a small listing. The test program opens a panel and
show a bitmap.
What I want is to when the mouse is over the bitmap panel, I want to
trap the left mouse click.
The...
|
by: Bruce A. Julseth |
last post by:
I have:
If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then
TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text,
TextBox1.Text.Length - 1)
End If
Adding: Imports...
|
by: James Brown [MVP] |
last post by:
Hi,
I am having trouble understanding how the 'const' modifier affects the
'left-right' rule when deciphering c-declarations:
const int *x; // x is a pointer to a 'const int'
int const *x; ...
|
by: Chaitanya |
last post by:
Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this "3145728". But the MouseButtons Enum
contains only Left,...
|
by: |
last post by:
What are the equivalant to left, right, etc. in C#. How can I extract
strings from a string without them? For instance, I have a string like so:
...
|
by: TheServant |
last post by:
Hi guys,
I have done this before, but I can't figure out why it won't work. If any of you can see my problem, please let me know. Here are the relavent pieces of code.
<!-- Main Content -->
<div...
|
by: shapper |
last post by:
Hello,
I am used to SQL but I am starting to use LINQ.
How can I create Left, Right and Inner joins in LINQ? How to
distinguish the different joins?
Here is a great SQL example:...
|
by: ImpactMan |
last post by:
Need help to create an windows mobile application with a few buttons that when they are pressed/clicked they assign keys, like up, down, left, right.
It is just like to create a "virtual d-pad",...
|
by: garfieldsevilla |
last post by:
I have a report in Access 2003 which consists of a header with two fields and a subform pasted into the centre.
When I open this form, it always displays in Print Preview and I cannot find an...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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: 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,...
|
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...
|
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,...
|
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...
| | |