Martin2k Forums

Board index Visual Basic Visual Basic Tutorials, Tricks & Tips

Get HTML Source Code Without using an Inet Control

This is where you can post your VB & VB.Net Tutorials, Tricks & Tips.

Get HTML Source Code Without using an Inet Control

Postby Mark » Thu May 12, 2011 12:50 pm

Getting HTML source can be done without using a webbrowser or inet control. The other option is using the Microsoft.XMLHTTP object.

Code: Select all
Option Explicit

' This sample uses
' 1 textbox
' 1 command button
' 1 richtextbox
Private Sub cmdGetHtml_Click()
Dim strURL As String
Dim objHTML


    strURL = txtURL.Text
    Set objHTML = CreateObject("Microsoft.XMLHTTP")
    objHTML.open "GET", strURL, False
    objHTML.send

    rtbHTML.Text = objHTML.responseText

    Set objHTML = Nothing

End Sub

Private Sub Form_Load()
    txtURL.Text = "http://www.martin2k.co.uk/forums/index.php"
End Sub
Mark
Moderator
 
Posts: 129
Joined: Wed Dec 01, 2010 5:40 pm
Medals: 1
6 Star (1)

Re: Get HTML Source Code Without using an Inet Control

Postby Keith » Thu May 12, 2011 7:24 pm

Is this for the benefit of Syntax Highlighting Mark?

They are trying to get VB code to show the same as it does in A1vbcode with your syntax.zip
I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Image
Keith
Administrator
 
Posts: 869
Joined: Tue Oct 13, 2009 12:15 am
Location: Stoke on Trent, England
Medals: 1
6 Star (1)

Re: Get HTML Source Code Without using an Inet Control

Postby Mark » Thu May 12, 2011 7:49 pm

If A1vbcode had at least done indenting I probably would have never created the syntax highlighting project. I can do without the fancy color but just hate reading code that isn't indented properly.
Mark
Moderator
 
Posts: 129
Joined: Wed Dec 01, 2010 5:40 pm
Medals: 1
6 Star (1)

Re: Get HTML Source Code Without using an Inet Control

Postby xela » Fri May 13, 2011 1:56 am

Option Explicit

' This sample uses
' 1 textbox
' 1 command button
' 1 richtextbox
Private Sub cmdGetHtml_Click()
Dim strURL As String
Dim objHTML


strURL = txtURL.Text
Set objHTML = CreateObject("Microsoft.XMLHTTP")
objHTML.open "GET", strURL, False
objHTML.send

rtbHTML.Text = objHTML.responseText

Set objHTML = Nothing

End Sub

Private Sub Form_Load()
txtURL.Text = "http://www.martin2k.co.uk/forums/index.php"
End Sub
?
xela
Holy
 
Posts: 4608
Joined: Sun Feb 13, 2011 12:05 am
Location: NOT TOO FAR AWAY FROM ESSEX, FAIR DISTANCE FROM THE OC LIKE!
Medals: 3
6 Star (1) Ginger Medal (1) Flug Collaboration (1)

Re: Get HTML Source Code Without using an Inet Control

Postby Jag9 » Fri May 13, 2011 3:46 am

I'm glad that someone agrees with me about the indenting. I can't stand code that isn't correctly indented.

However, Mark, if you try editing your original post in this topic and replaced the "code" tag with "vb" then it should also include the syntax highlighting that Keith has already mentioned. That's one of the modifications I've been working on today.

Also, Keith, I understand you still have a problem with uploading a .txt file containing VB code (along with line numbers)... I'll look into it when I'm sober.

Spoiler: show
Alex, I love you.
/ Matty
User avatar
Jag9
Level 3
 
Posts: 1497
Joined: Thu Oct 15, 2009 3:56 pm
Location: Liverpool, UK
Medals: 2
6 Star (1) Flug Collaboration (1)


Return to Visual Basic Tutorials, Tricks & Tips

Who is online

Users browsing this forum: No registered users and 0 guests