473,721 Members | 4,027 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 200972
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
3607
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 intercepted. I new to Python and wxWindows so any help would be greatly appreciated.
8
38647
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
5111
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
2220
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
4633
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 click not added to the Enum? Can anyone help me?
5
3044
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\" which may be different, and the file name minus the extension and the "___Selected" portion, so return...
14
2681
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
11919
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
4100
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 for it only result in this simple code lines:
0
1428
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 borders present in all Windows do now show. If you zoom in, the right scroll border will show but...
0
9373
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9143
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8019
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5992
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4497
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2588
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2137
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.