PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Convert string to URL-VBForums
Results 1 to 12 of 12

Thread: Convert string to URL

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Convert string to URL

    This question is so easy I am embarressed.
    vs 2005

    Confusion exists within my realm today.

    How oh how to covert :

    "http://www.vbforums.com" to a url so I can make my embedded browser make use of it in my windows application.

    Lordy I am thick.

    Parksie

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,724

    Re: Convert string to URL

    If you mean a Uri object so that you can assign it to the WebBrowser.Url property then don't even bother. Just call Navigate and pass the String.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,724

    Re: Convert string to URL

    For future reference, the Uri class has several constructors that take a URL string as an argument.

  4. #4

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Convert string to URL

    I picked up the code from :
    http://www.c-sharpcorner.com/Code/2004/Sept/WebBrowserControl.asp

    And this in particular :

    VB Code:
    1. private void BrowseBtn_Click(object sender, EventArgs e)
    2. {
    3. webBrowser1.Url = UrlTextBox.Text;
    4. }

    Pain in the Pensi.

    Parksie

  5. #5
    Hyperactive Member Mosabama's Avatar
    Join Date
    Aug 2004
    Location
    Mars
    Posts
    306

    Re: Convert string to URL

    isnt a url a string actually ?!!!
    My software never has bugs. It just develops random features.
    I RATE, YOU RATE!!!

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,724

    Re: Convert string to URL

    Quote Originally Posted by Mosabama
    isnt a url a string actually ?!!!
    The Url property of the WebBrowser control is a Uri object. This is basically a wrapper for a URL string that allows you to do certain things with it in one line of code by using its properties and methods rather than writing your own code every time.

  7. #7
    New Member
    Join Date
    May 2008
    Posts
    2

    Re: Convert string to URL

    I'm using Microsoft VB 2005. In a Windows Application, the WebBrowser.Navigate() accepts a string argument. In a Windows Embedded CE 5.0 application, it only accepts a Uri. So, where can I find a method or a snippet to convert?

  8. #8
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: Convert string to URL

    Create a new Uri and pass the string in the constructor.

    C# Code:
    1. Uri myUri = new Uri("http://www.vbforums.com")
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  9. #9
    New Member
    Join Date
    May 2008
    Posts
    2

    Re: Convert string to URL

    Thanks, yes that does work. I used an argument of the form (TextBox1.Text) rather than a quoted string, and that works OK. One caution is that the argument must be an absolute URL or it causes a runtime exception.

  10. #10
    New Member
    Join Date
    Oct 2008
    Posts
    1

    Thumbs up Re: Convert string to URL

    Quote Originally Posted by Atheist
    Create a new Uri and pass the string in the constructor.

    C# Code:
    1. Uri myUri = new Uri("http://www.vbforums.com")

    it works perfectly I was looking for it so much.
    thank Atheist

  11. #11
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: Convert string to URL

    Quote Originally Posted by mohkami

    it works perfectly I was looking for it so much.
    thank Atheist
    You're welcome!
    And welcome to VBForums
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  12. #12
    New Member
    Join Date
    Aug 2010
    Posts
    1

    Re: Convert string to URL

    why dont just use WebBrowser.Navigate()?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width