Advertisement
Guest User

code get select from page

a guest
May 25th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1.  
  2. Private Sub BTNGetLanguaje_Click(sender As Object, e As EventArgs) Handles BTNGetLanguaje.Click
  3.  
  4. 'this will get the source code of the page that i want to extract the languages
  5. Scrapping.DownloadHtmlPage("Http://prod.etim-international.com/class", tbHTMLSourceCodeLanguage)
  6.  
  7. 'this will clear the code (Remove the quotes)
  8. Scrapping.ClearHtmlTB(tbHTMLSourceCodeLanguage)
  9.  
  10.  
  11. 'this will get only the option select which contains the languages option
  12. 'first declare my variables start tag, end tag, and htmlcode
  13. Dim starttag = "name=#LanguageCode#>"
  14. Dim endtag = "</select> "
  15. Dim htmlcode = tbHTMLSourceCodeLanguage.Text
  16. 'this will place the result in the textbox tbhtmlsourcecodelanguage
  17. Scrapping.FindTextBetweenTags(starttag, endtag, htmlcode, tbHTMLSourceCodeLanguage)
  18.  
  19. ' everything that is between the tags options will be added to listbox1
  20. Dim starttaglistbox = "<option"
  21. Dim endtaglistbox = "</option>"
  22.  
  23. Scrapping.AddMatchToListBox(tbHTMLSourceCodeLanguage, starttaglistbox, endtaglistbox, ListBox1)
  24.  
  25. 'for every item in listbox do the following
  26. For Each item In ListBox1.Items
  27. TBLanguageHelper.Text = "" 'this will clear the textbox so a value can be placed
  28. TBLanguageHelper.Text = item 'this will make the textbox equal to the value of the item
  29.  
  30. 'this will remove part of the tags before the value option
  31. 'we do this to keep the value so when we go to the click method we will have the rigth value
  32. TBLanguageHelper.Text = TBLanguageHelper.Text.Replace("</option>", "")
  33.  
  34. TBLanguageHelper.Text = TBLanguageHelper.Text.Replace("<option value=#", "")
  35.  
  36. TBLanguageHelper.Text = TBLanguageHelper.Text.Replace("<option selected=#selected# value=#", "")
  37.  
  38. CBLanguages.Items.Add(TBLanguageHelper.Text)
  39.  
  40. Next
  41.  
  42.  
  43. End Sub
  44.  
  45. Private Sub CBLanguages_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CBLanguages.SelectedIndexChanged
  46.  
  47.  
  48.  
  49. tbvalue.Text = CBLanguages.Text
  50.  
  51. 'this will keep only 2 digits
  52. tbvalue.Text = tbvalue.Text.Substring(0, 2)
  53.  
  54.  
  55. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement