Results 1 to 2 of 2

Thread: [2008] display varying picture with substring

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2008
    Location
    Altoona, PA
    Posts
    242

    [2008] display varying picture with substring

    I'm trying to display a picture inside of a picture box with a url using substring.
    While testing it out i just made a text box that displays the source of the webbrowser page with the picture.
    The problem is the image url is inside quotations.So, it confuses vb since i have it in like this...




    Dim str As String

    str = (TextBox1.Text.ToString)


    PictureBox1.ImageLocation = (str.Trim.Substring(str.Trim.IndexOf("src="), (str.Trim.Length - str.Trim.IndexOf("src="))))


    PictureBox1.ImageLocation = (str.Trim.Substring(0, str.Trim.IndexOf(" alt=")))




    In the source of the HTML it has the image location in quotations so when it's going to the image location it's trying to show this location..

    "http://itemdb-rs.runescape.com/2365_obj_big.gif?id=2861"

    So, is there a way to get it to ignore the quotation marks? And go to what's inside of them?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] display varying picture with substring

    You can use Trim to remove leading and trailing characters. Without parameters it removes whitespace but you can specify characters to trim.

    That said, you'd be better off using a Regex to get the URL without all that rigmarole. There will undoubtedly be examples on the forum already so you should search.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width