473,574 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 200852
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(sta rt)
s = s.Substring(sta rt, 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]@cooltoolsonlin e.co.uk
-- remove [nospam] to email me --
"ReidarT" <re****@eivon.n o> wrote in message
news:u6******** ******@TK2MSFTN GP09.phx.gbl...
How do I use left, mid and right in vb.net?
regards
reidarT

Nov 21 '05 #2
* "ReidarT" <re****@eivon.n o> 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.n o> wrote in message
news:u6******** ******@TK2MSFTN GP09.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_TextCh anged(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles TextBox1.TextCh anged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.n o> skrev i melding
news:u6******** ******@TK2MSFTN GP09.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]@cooltoolsonlin e.co.uk
-- remove [nospam] to email me --
"ReidarT" <re****@eivon.n o> wrote in message
news:%2******** *******@TK2MSFT NGP11.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_TextCh anged(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles TextBox1.TextCh anged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.n o> skrev i melding
news:u6******** ******@TK2MSFTN GP09.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***@cooltool sonline.co.uk> wrote in message
news:uq******** ******@tk2msftn gp13.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]@cooltoolsonlin e.co.uk
-- remove [nospam] to email me --
"ReidarT" <re****@eivon.n o> wrote in message
news:%2******** *******@TK2MSFT NGP11.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_TextCh anged(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles TextBox1.TextCh anged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.n o> skrev i melding
news:u6******** ******@TK2MSFTN GP09.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.Visua lBasic
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_TextCh anged(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles TextBox1.TextCh anged
Dim s As String
s = TextBox1.Text
s = Mid(s, 3, 4)
Label1.Text = s
End Sub
reidarT

"ReidarT" <re****@eivon.n o> skrev i melding
news:u6******** ******@TK2MSFTN GP09.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
3598
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 purpose is to get the position of the mouse pointer on the bitmap. However, for some reason, the left (I also tried right) mouse clicks are not...
8
38625
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
5100
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 Microsoft.VisualBasic
6
2213
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; // ?? these are the same, right? in this case the basetype is 'const int' ? int * const x = 0; // x is a const-pointer to int
8
4609
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, Right, Middle, None, XButton1 and XButton2. I am using .NET 1.1 version. How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right...
5
3032
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: "c:\thedir\subfolder\maybeanother\__TFMF_lrniez55ufziugv2nnznzeyt_b9c9c1d5-230a-43e1-b38a-7a44_0___Selected.eps" I need to return just the directory name "c:\thedir\subfolder\maybeanother\"...
14
2672
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 class="main_content"> <!-- Content --> <div class="content"> <p>main content</p> </div> <!-- End of Content -->
9
11913
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: http://www.codinghorror.com/blog/archives/000976.html
16
4088
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", or "software emulated d-pad". I'm newbie in programming, and I'm using Visual Studio 2008. Some one can help me with that? Tanks. My effort...
0
1421
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 setting for default view. I would prefer it showed in Layout Preview. Can anyone help with this setting? Also in Print Preview, the left, right and top...
0
7835
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
8265
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8132
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
6500
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...
1
5645
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5332
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
3769
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...
1
1365
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1096
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.