Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is There Right, or Left in VB 2005? 1

Status
Not open for further replies.

NerdTop72

Programmer
Mar 14, 2005
117
US
what happend to Left(String,length from left)
and Right(String,Length from right)

I have mid but come on!
Thanks
 
Microsoft.VisualBasic.Left(x, 5)
Microsoft.VisualBasic.Right(x, 5)

 
Microsoft.VisualBasic is available essentially for backward compatibility (and to ease the transfer process to .Net).

The ".Net way" is to use String.Substring as in:

Code:
  Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

    Dim s As String = "This is a string"

    MessageBox.Show(s.Substring(0, 4))  ' = left
    MessageBox.Show(s.Substring(s.Length - 6)) ' =  right

  End Sub


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top