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

left, mid and right in vb.net

How do I use left, mid and right in vb.net?
regards
reidarT

Nov 21 '05 #1
7 200737
Hello,

If you declare a string and you can simply use the functions as follows:-

Dim s As String
s = Left(s, length)
s = Mid(s, start, length)
s = Right(s, length)

Substring function is provided instead of using of the above.

E.g.

Dim s As String
s = s.SubString(start)
s = s.Substring(start, length)

Where start = the index of the character to start from,
and length = the number of characters to take.

Hope this helps,
Simon Jefferies
mailto:simon[nospam]@cooltoolsonline.co.uk
-- remove [nospam] to email me --
"ReidarT" <re****@eivon.no> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT

Nov 21 '05 #2
* "ReidarT" <re****@eivon.no> scripsit:
How do I use left, mid and right in vb.net?


I qualify these methods with the module that contains them:

'Strings.Left', 'Strings.Right', 'Strings.Mid'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Left:
http://msdn.microsoft.com/library/de.../vafctLeft.asp
Right:
http://msdn.microsoft.com/library/de...vafctright.asp
Mid:
http://msdn.microsoft.com/library/de...l/vafctmid.asp

"ReidarT" <re****@eivon.no> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT


Nov 21 '05 #4
if I use the mid-function, it works, but if I use left-function it does not
work
Here is the code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.no> skrev i melding
news:u6**************@TK2MSFTNGP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT

Nov 21 '05 #5
Hello,

In what way does it not work?

You seem to be retrieving the middle part of a string from a textbox entry,
where as using the Left function is to return the leftmost characters only.
You may get an error if you try to retrieve letters from a string when there
aren't enough in it?

Regards
Simon Jefferies
mailto:simon[nospam]@cooltoolsonline.co.uk
-- remove [nospam] to email me --
"ReidarT" <re****@eivon.no> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
if I use the mid-function, it works, but if I use left-function it does
not
work
Here is the code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.no> skrev i melding
news:u6**************@TK2MSFTNGP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT


Nov 21 '05 #6
I enjoy watching these threads, the irritation is muted but obvious
nevertheless ;-)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Simon Jefferies" <si***@cooltoolsonline.co.uk> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
Hello,

In what way does it not work?

You seem to be retrieving the middle part of a string from a textbox entry, where as using the Left function is to return the leftmost characters only. You may get an error if you try to retrieve letters from a string when there aren't enough in it?

Regards
Simon Jefferies
mailto:simon[nospam]@cooltoolsonline.co.uk
-- remove [nospam] to email me --
"ReidarT" <re****@eivon.no> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
if I use the mid-function, it works, but if I use left-function it does
not
work
Here is the code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.no> skrev i melding
news:u6**************@TK2MSFTNGP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT



Nov 21 '05 #7
It may be that Left is a property of forms and controls and if this is used
in a Form class, it probably won't work. Try importing Microsoft Visual
Basic like

Imports vb = Microsoft.VisualBasic
You can then use VB.Left(xxx,3) or whatever.

"ReidarT" wrote:
if I use the mid-function, it works, but if I use left-function it does not
work
Here is the code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.no> skrev i melding
news:u6**************@TK2MSFTNGP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT


Nov 21 '05 #8

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

Similar topics

3
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...
8
by: A.M | last post by:
Hi, Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6? Thanks, Alan
11
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...
6
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; ...
8
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,...
5
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: ...
14
TheServant
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...
9
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:...
16
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",...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
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
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.