Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › [Help] Problem reading text from a webpage

[Help] Problem reading text from a webpage

Posts 1–15 of 19 · Page 1 of 2
Jason
Jason
[Help] Problem reading text from a webpage
Hey guys. I'm trying to use StreamReader to read all the text in a .txt document I uploaded on my ftp site...

I'm currently using this to read 4 different text documents and print them into a label...

[php]
Dim url1, url2, url3, url4 As String
url1 = "http://mywebsite/TextDocument1.txt"
url2 = "http://mywebsite/TextDocument2.txt"
url3 = "http://mywebsite/TextDocument3.txt"
url4 = "http://mywebsite/TextDocument4.txt"

Dim request1, request2, request3, request4 As System.Net.HttpWebRequest

request1 = System.Net.HttpWebRequest.Create(url1)
request2 = System.Net.HttpWebRequest.Create(url2)
request3 = System.Net.HttpWebRequest.Create(url3)
request4 = System.Net.HttpWebRequest.Create(url4)

Dim response1, response2, response3, response4 As System.Net.HttpWebResponse
response1 = request1.GetResponse()
response2 = request2.GetResponse()
response3 = request3.GetResponse()
response4 = request4.GetResponse()

Dim sr1, sr2, sr3, sr4 As System.IO.StreamReader

sr1 = New System.IO.StreamReader(response1.GetResponseStream (), System.Text.Encoding.GetEncoding("windows-1252"))
sr2 = New System.IO.StreamReader(response2.GetResponseStream (), System.Text.Encoding.GetEncoding("windows-1252"))
sr3 = New System.IO.StreamReader(response3.GetResponseStream (), System.Text.Encoding.GetEncoding("windows-1252"))
sr4 = New System.IO.StreamReader(response4.GetResponseStream (), System.Text.Encoding.GetEncoding("windows-1252"))

Dim Online1, Online2, Online3, Online4 As String
Online1 = sr1.ReadToEnd()
Online2 = sr2.ReadToEnd()
Online3 = sr3.ReadToEnd()
Online4 = sr4.ReadToEnd()

Label2.Text = ("1. " + Online1)
Label3.Text = ("2. " + Online2)
Label4.Text = ("3. " + Online3)
Label5.Text = ("4. " + Online3)

[/php]

Only trouble is, nothing happens O.o

Any glaring errors in my code?
#1 · 16y ago
Hassan
Hassan
First, use this function:

Code:
 
Function GetPage(ByVal pageUrl As String) As String
	  Dim s As String = ""
	  Try
		 Dim request As HttpWebRequest = WebRequest.Create(pageUrl)
		 Dim response As HttpWebResponse = request.GetResponse()
		 Using reader As StreamReader = New StreamReader(response.GetResponseStream())
			s = reader.ReadToEnd()
		 End Using
	  Catch ex As Exception
		 Debug.WriteLine("FAIL: " + ex.Message)
	  End Try
	  Return s
   End Function
Then, Try this.

Code:
Dim url1, url2, url3, url4 As String
        url1 = "http://mywebsite/TextDocument1.txt"
        url2 = "http://mywebsite/TextDocument2.txt"
        url3 = "http://mywebsite/TextDocument3.txt"
        url4 = "http://mywebsite/TextDocument4.txt"
Dim Online1, Online2, Online3, Online4 As String 
Online1 = GetPage(url1)
Online2 = GetPage(url2)
Online3 = GetPage(url3)
Online4 = GetPage(url4)
#2 · 16y ago
Jason
Jason
Quote Originally Posted by FLAMESABER View Post
First, use this function:

Code:
 
Function GetPage(ByVal pageUrl As String) As String
	  Dim s As String = ""
	  Try
		 Dim request As HttpWebRequest = WebRequest.Create(pageUrl)
		 Dim response As HttpWebResponse = request.GetResponse()
		 Using reader As StreamReader = New StreamReader(response.GetResponseStream())
			s = reader.ReadToEnd()
		 End Using
	  Catch ex As Exception
		 Debug.WriteLine("FAIL: " + ex.Message)
	  End Try
	  Return s
   End Function
Then, Try this.

Code:
Dim url1, url2, url3, url4 As String
        url1 = "http://mywebsite/TextDocument1.txt"
        url2 = "http://mywebsite/TextDocument2.txt"
        url3 = "http://mywebsite/TextDocument3.txt"
        url4 = "http://mywebsite/TextDocument4.txt"
Dim Online1, Online2, Online3, Online4 As String 
Online1 = GetPage(url1)
Online2 = GetPage(url2)
Online3 = GetPage(url3)
Online4 = GetPage(url4)
Can I have your children?

Thanks so much man, works beautifully and so much less messy Thanks.
#3 · 16y ago
Hassan
Hassan
Quote Originally Posted by J-Deezy View Post
Can I have your children?

Thanks so much man, works beautifully and so much less messy Thanks.
No, I love my children...lol

No problem...*cough* thnx !! ?
xD
#4 · 16y ago
Jason
Jason
Quote Originally Posted by FLAMESABER View Post
No, I love my children...lol

No problem...*cough* thnx !! ?
xD
I meant can I make you some more silly

I pressed thanks!
#5 · 16y ago
Hassan
Hassan
Quote Originally Posted by J-Deezy View Post
I meant can I make you some more silly

I pressed thanks!
No, you can't...and thnx
#6 · 16y ago
MvRouC12
MvRouC12
Oh wow, and thanks. haha solved tag anyone?
#7 · 16y ago
Jason
Jason
Hey Flame if you happen to look at this thread again, is it possible to read one line, save it to a string variable, read the next line, save it to another string variable...etc
#8 · 16y ago
Blubb1337
Blubb1337
Code:
While Not reader.EndOfStream

            Dim s As String = reader.ReadLine
           
        End While
You may do something like...

Code:
if s.startswith("abc")...
Code:
if s.contains("def")...
I don't know how to declare a new variable for each line. You may use a hidden listbox or idk...tell me exactly why/how you want to do that ^.-
#9 · 16y ago
Jason
Jason
Well basically what I want to do is have a few things associated to a general topic that I save in a text document.

i.e my text document is set out like this

[php]
NAME
LINK
LINK2
[/php]

But I want to read the line that contains the line and assign it to a label
then I want to read second line and assign that to another string variable

I.e (this isn't actual code obviously but I hope it helps you understand better what i mean)

[php]

Dim DocName, DocLink1, DocLink2 as string
Dim request As HttpWebRequest = WebRequest.Create(pageUrl)
Dim response As HttpWebResponse = request.GetResponse()
Using reader As StreamReader = New StreamReader(response.GetResponseStream())

DocName = reader.ReadLine1
DocLink1 = reader.ReadLine2
DocLink2 = reader.ReadLine3

end using

[/php]

But you can't tell it what line to read :O
#10 · 16y ago
Blubb1337
Blubb1337
One second....
#11 · 16y ago
Jason
Jason
Quote Originally Posted by Blubb1337 View Post
One second....

........one
#12 · 16y ago
Blubb1337
Blubb1337
Fu.

Add the following function:

Code:
  Public Shared Function ReadSpecifiedLine(ByVal file As String, ByVal lineNum As Integer) As String
        'create a variable to hold the contents of the file
        Dim contents As String = String.Empty
        'always use a try...catch to deal
        'with any exceptions that may occur
        Try
            Using stream As New StreamReader(file)
                contents = stream.ReadToEnd().Replace(vbCr & vbLf, vbLf).Replace(vbLf & vbCr, vbLf)
                Dim linesArray As String() = contents.Split(New Char() {ControlChars.Lf})

                'Make sure we have ana ctual array
                If linesArray.Length > 1 Then
                    'Make sure user didnt provide number greater than the number
                    'of lines in the array, and not less than 0 (zero) Thanks AdamSpeight2008
                    If Not lineNum > linesArray.Length AndAlso Not lineNum < 0 Then
                        Return linesArray(lineNum)
                    Else
                        'Failed our check so return the first line in the array
                        Return linesArray(0)
                    End If
                Else
                    'No array so return the line
                    Return contents
                End If
            End Using
        Catch ex As Exception
            Return ex.ToString()
        End Try
    End Function
Code:
Dim s as string = reader.readtoend
Code:
DocName = ReadSpecifiedLine(s, 0)         
            DocLink1 = ReadSpecifiedLine(s, 1)
            DocLink2 = ReadSpecifiedLine(s, 2)
Eating, fu again.
#13 · edited 16y ago · 16y ago
Jason
Jason
Quote Originally Posted by Blubb1337 View Post
Fu.

Add the following function:

Code:
  Public Shared Function ReadSpecifiedLine(ByVal file As String, ByVal lineNum As Integer) As String
        'create a variable to hold the contents of the file
        Dim contents As String = String.Empty
        'always use a try...catch to deal
        'with any exceptions that may occur
        Try
            Using stream As New StreamReader(file)
                contents = stream.ReadToEnd().Replace(vbCr & vbLf, vbLf).Replace(vbLf & vbCr, vbLf)
                Dim linesArray As String() = contents.Split(New Char() {ControlChars.Lf})

                'Make sure we have ana ctual array
                If linesArray.Length > 1 Then
                    'Make sure user didnt provide number greater than the number
                    'of lines in the array, and not less than 0 (zero) Thanks AdamSpeight2008
                    If Not lineNum > linesArray.Length AndAlso Not lineNum < 0 Then
                        Return linesArray(lineNum)
                    Else
                        'Failed our check so return the first line in the array
                        Return linesArray(0)
                    End If
                Else
                    'No array so return the line
                    Return contents
                End If
            End Using
        Catch ex As Exception
            Return ex.ToString()
        End Try
    End Function
Code:
Dim s as string = reader.readtoend
Code:
DocName = ReadSpecifiedLine(s, 0)         
            DocLink1 = ReadSpecifiedLine(s, 1)
            DocLink2 = ReadSpecifiedLine(s, 2)
Eating, fu again.
hehehe thanks Blubb, I'll go checkit out now! My back is like crippled so im bored as fuck
#14 · 16y ago
Blubb1337
Blubb1337
Code something for me, no I don't know what x_X.

U no onlaine @ msn?
#15 · 16y ago
Posts 1–15 of 19 · Page 1 of 2

Post a Reply

Similar Threads

  • [help]read text from an online .txt[Solved]By trevor206 in Visual Basic Programming
    10Last post 15y ago
  • [Help]VB Read text file[Solved]By mo3ad001 in Visual Basic Programming
    3Last post 16y ago
  • [Help]How to draw text from a file?By seeplusplus in Combat Arms Coding Help & Discussion
    29Last post 15y ago
  • Reading lines from text file?By ppl2pass in Visual Basic Programming
    4Last post 16y ago
  • Any1 from EU i need your help::: MUST READ EU USERS:::By headsup in Combat Arms Europe Hacks
    1Last post 17y ago

Tags for this Thread

None