Imports System.Net
Imports System.Data
Imports System.IO
Imports System.Text.RegularExpressions
Public Class Form1
Public Shared Function GetPageAsString(ByVal address As String) As String
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim result As String
Try
Try
' Create the web request
request = DirectCast(WebRequest.Create(address), HttpWebRequest)
' Get response
response = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader = New StreamReader(response.GetResponseStream())
' Read the whole contents and return as a string
result = reader.ReadToEnd()
Finally
If Not response Is Nothing Then response.Close()
End Try
Catch ex As Exception
End Try
Return result
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = GetPageAsString(TextBox1.Text) '<-url
Dim str1 As String = "
Dim str2 As String = "
' Declare iteration variable
Dim s As String
' Loop through words in string
Dim arr As String() = SplitWords(TextBox2.Text)
' Display each word. Note that punctuation is handled correctly.
For Each s In arr
Dim b As Integer = 0
Dim a As String = s
If a = "Trenutna" Then b += 1
If a = "kn" Then b += 1
If b > 0 Then TextBox3.Text += a
If b = 2 Then GoTo bbb
Next
bbb:
End Sub
Private Function SplitWords(ByVal s As String) As String()
Return Regex.Split(s, "\W+")
End Function
End Class
Replies
Know the answer? Post it — somebody with the same question will find it here.