1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

URI Manipulation with .Net's URI Class

Discussion in 'Visual Basic [VB]' started by pradeep, Mar 27, 2007.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Uniform Resource Identifiers (URIs) may represent Web requests, FTP requests, files, news, and e-mail. Whenever you need to work with URIs and determine a particular portion of a given URI, you can utilize the System.URI class available in Visual Studio .NET. This class allows you to represent and easily manipulate a given URI.

    To create an example, add a ListBox control to your form and call it ListBox1. Then, add the code in Snippet A.

    Snippet A

    Code:
    Private Sub GetURIInfo()
          Dim strURI As New Uri("http://www.go4expert.com/showthread.php?p=10432")
          With ListBox1.Items
              .Clear()
              .Add("Scheme: " & strURI.Scheme)
              .Add("Host: " & strURI.Host)
              .Add("Path: " & strURI.AbsolutePath)
              .Add("Query: " & strURI.Query)
              .Add("Type: " & strURI.HostNameType.ToString())
              .Add("Port: " & strURI.Port)
          End With
      End Sub
    In the code, we initially define a strURI variable and set its value to a link from the Go4Expert forums. Then, we add the following properties of the URI object strURI to the ListBox1 control: Scheme, Host, Path, Query, Type, Port. The ListBox1 control simply displays the selected properties of the strURI object.
     

Share This Page