469,301 Members | 2,272 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,301 developers. It's quick & easy.

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 197965
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mitsura | last post: by
8 posts views Thread by A.M | last post: by
11 posts views Thread by Bruce A. Julseth | last post: by
6 posts views Thread by James Brown [MVP] | last post: by
5 posts views Thread by | last post: by
TheServant
14 posts views Thread by TheServant | last post: by
9 posts views Thread by shapper | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.