VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A very simple html editor. Web-browser displays the results of your html code as you type in textbo

by Hugh Musser (8 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 11th March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A very simple html editor. Web-browser displays the results of your html code as you type in textbox.

API Declarations


Add a richtextbox named RichTextBox1.
Add a web-browser named WebBrowser1.
In Project Referances, add a referance to "Microsoft HTML Object Library."
Copy the code below to your form.

Rate A very simple html editor. Web-browser displays the results of your html code as you type in textbo




'For the following, add a referance to
'Microsoft HTML Object Library

Private WithEvents docHTML As HTMLDocument

Private Sub Form_Load()
 With WebBrowser1
    .Navigate ":About" 'activate webbrowser
    .Top = 0
    .Left = 0
    .Width = Screen.Width - 6
    .Height = (Screen.Height / 2) - 6
End With
With RichTextBox1
    .Top = (Screen.Height / 2) - 3
    .Left = 0
    .Height = (Screen.Height / 2) - 6
    .Width = Screen.Width - 6
End With
End Sub

Private Sub RichTextBox1_Change()
Dim Obj As Object
    On Error Resume Next
    docHTML.open
    'if dochtml not active,create it
    If Err.Number = 91 Then Set docHTML = WebBrowser1.Document: docHTML.open
    On Error GoTo 0
    Set Obj = docHTML 'create object to write in
    Obj.write RichTextBox1.Text 'copy textbox into webdocument
    docHTML.Close
    Set Obj = Nothing
End Sub

Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
'---------capture tab key-----------
If KeyCode = 9 Then
    RichTextBox1.Text = RichTextBox1.Text & vbTab
    KeyCode = 35 'apply end key to textbox
End If
End Sub



Download this snippet    Add to My Saved Code

A very simple html editor. Web-browser displays the results of your html code as you type in textbo Comments

No comments have been posted about A very simple html editor. Web-browser displays the results of your html code as you type in textbo. Why not be the first to post a comment about A very simple html editor. Web-browser displays the results of your html code as you type in textbo.

Post your comment

Subject:
Message:
0/1000 characters