Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Imports

 

You need to import the namespace that includes the Left function.

Include this first in your code, before any declaration.

 

Imports Txt = Microsoft.VisualBasic.Strings

 

You can then use the following syntax to access the Left function.

 

Txt.Left("testing,2)

 

You can you the Object Browser to search for the function you are looking for and then include the required namespace using Imports.

Posted

Thank you! currently I am using SubString to replace left and right. But "Mid" is still available right?

 

Just felt that "Right" is not so conveninet to replace with SubString...:)

  • 2 weeks later...
Posted

Mid() is still available, which you can use to do anything you could with left() or right() functions, also you can use substring like stated above, and you can still use instr() and instrrev()

 

so everything should be peachy!

mod2software

Home of the VB.NET Class Builder Utility - Demo and Full versions available now!

Posted
I might be me, but I can't use substring to replace chars within strings like I can with mid. I have tried to use Insert but it doesn't seem to replace, it only inserts new chars.
  • Leaders
Posted

you certainly can replace chars with SubString :) eg:

       Dim strString As String = "abc123"
       Dim strNewString As String = strString.Replace(strString.Substring(1, 1), "B")
       MessageBox.Show(strNewString) '/// b will be replaced with B

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...