By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Search a textbox for particular text

P: 32
hi in a project that im working on i load a web page source into a textbox and then from that text i try to find files on the web page and then makes a new item in a listbox with the file name text as the item text e.g(http://bytes.com/images/logo4.gif) (then you can download the file). I kinda got a way of doin it but it doesent work any good. The download part works perfect its just the finding files in the source.

I came up with this coding and there are 4 things wrong with it
1. way to long
2.doesent always find files
3. mostly it comes up with stuff like "httpgif"
4. sometimes come up with errors


Expand|Select|Wrap|Line Numbers
  1.   Dim flv_reader As String = String.Empty
  2.         Dim e As Integer = 0
  3.         Dim flv_eq As Integer = 0
  4.         Dim flv_dot As Integer = 0
  5.         Dim flv_file As String = String.Empty
  6.         For e = 0 To txts.Lines.Length - 1
  7.             flv_reader = txts.Lines(e)
  8.             'find the .swf
  9.             If flv_reader.Contains(".flv") Then
  10.                 'find the :
  11.                 Dim f As Integer = 0
  12.                 For f = 0 To flv_reader.Length - 1
  13.                     If flv_reader.Chars(f) = ":" Then
  14.                         flv_eq = f
  15.                     End If
  16.                 Next
  17.                 'find the .
  18.                 Dim g As Integer = flv_eq
  19.                 For g = flv_eq To flv_reader.Length - 1
  20.                     If flv_reader.Chars(g) = "." Then
  21.                         flv_dot = g
  22.                     End If
  23.                 Next
  24.                 'Me.Text = swf_dot
  25.                 'get text betwwen the 2
  26.                 Dim h As Integer = 0
  27.                 For h = flv_eq To flv_dot
  28.                     flv_file += flv_reader.Chars(h)
  29.                 Next
  30.                 'add http and swf
  31.                 flv_file = "http" + flv_file + "flv"
  32.                 'clean the search
  33.                 If flv_file.Contains("<") = False Then
  34.                     If flv_file.Contains("""") = False Then
  35.                         lstfiles.Items.Add(flv_file)
  36.                     End If
  37.                 End If
  38.             End If
  39.         Next
  40.  
Apr 11 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.