6 Replies - 903 Views - Last Post: 15 July 2011 - 12:29 AM Rate Topic: -----

#1 sha1023012  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-July 11

How to create a HTML editor im having a problem

Posted 14 July 2011 - 08:59 AM

Hello everyone,
I am working on this project and I am running into a few problems. Well Nothing is working but when you want to open a file.This is the project I have to do.
My project is allow the user to create a new HTML. Open an existing HTML file from your hard drive(which I don't understand that one). Save an HTML file.Also aloud the user to to load HTML file (source only ) From the internet, when the user selects this feature provide a text box and a button to enter the url. I know how to do a textbox and a button. Include an about me page with your name.I am kinda lost on that part with the textbox and url can someone help me.

Here is my code.

Imports System.IO
Imports System.Net

Public Class Form1


    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        Dim Open As New OpenFileDialog()
        Dim myStreamReader As System.IO.StreamReader
        Open.Filter = "Text[*.txt*]|*.txt|All Files[*.*]|*.*"
        Open.CheckFileExists = True
        Open.Title = "Open File"
        Open.ShowDialog(Me)
        Try
            Open.OpenFile()
            myStreamReader = System.IO.File.OpenText(Open.FileName)
            document.Text = myStreamReader.ReadToEnd()

        Catch ex As Exception

        End Try
    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        Dim Save As New SaveFileDialog()
        Dim myStreamWriter As System.IO.StreamWriter
        Save.Filter = "Text(*.txt)|*.txt|HTML(*.html*)|*.html|All Files(*.*)|*.*"
        Save.CheckPathExists = True
        Save.Title = "Save File"
        Save.ShowDialog(Me)
        Try
            myStreamWriter = System.IO.File.AppendText(Save.FileName)
            myStreamWriter.Write(document.Text)
            myStreamWriter.Flush()
        Catch ex As Exception
            'Do nothing on Exception
        End Try
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myRequest As WebRequest
        myRequest = WebRequest.Create("http://www.starkstate.edu")
        Dim theResponse As WebResponse = myRequest.GetResponse()
        Dim responseStream As Stream = theResponse.GetResponseStream()
        Dim reader As New StreamReader(responseStream)
    End Sub
End Class

This post has been edited by modi123_1: 14 July 2011 - 09:03 AM
Reason for edit:: please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: How to create a HTML editor im having a problem

#2 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: How to create a HTML editor im having a problem

Posted 14 July 2011 - 07:31 PM

This looks like .NET code. what version of vb are you using?

Jesse Fender
Was This Post Helpful? 0
  • +
  • -

#3 sha1023012  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-July 11

Re: How to create a HTML editor im having a problem

Posted 14 July 2011 - 08:44 PM

The book I am doing is Microsoft .net framework 3.5 window forms application development. I am using Visual basic express 2010 Express.
Was This Post Helpful? 0
  • +
  • -

#4 sha1023012  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-July 11

Re: How to create a HTML editor im having a problem

Posted 14 July 2011 - 08:51 PM

Hello everyone,

I am working on this project and I am getting confused. I have my basic Html editor. Now I am suppose to allow the user to load an HTML file(source code only) from the internet, when the user selects this feature provide a textbox and button to enter the URL. I have no clue how to do this. I been looking online and I am not finding anything it is not in my book either .. Can someone help me thanks here is my code I have so far.

Public Class Form1

    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        RichTextBox1.Text = ""

    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        Dim Open As New OpenFileDialog
        Open.FileName = ""
        Open.Filter = "htmlfile(*.html)|*.html"
        Open.Title = "open"
        Open.ShowDialog()
        Try
            Dim read As New System.IO.StreamReader(Open.FileName)
            RichTextBox1.Text = read.ReadToEnd
            read.Close()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        Dim save As New SaveFileDialog
        save.FileName = ""
        save.Title = "save"
        save.Filter = "htmlfile(*.html)|*.html"
        save.ShowDialog()
        Try
            Dim write As New System.IO.StreamWriter(save.FileName)
            write.Write(RichTextBox1.Text)
            write.Close()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub AboutMeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutMeToolStripMenuItem.Click
        Dim form = New Form
        Form2.Show()

    End Sub
End Class

This post has been edited by sha1023012: 14 July 2011 - 08:52 PM

Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 6436
  • View blog
  • Posts: 23,430
  • Joined: 12-June 08

Re: How to create a HTML editor im having a problem

Posted 14 July 2011 - 08:57 PM

Please stop opening duplicate posts. I am having this moved out the VB.NET side versus the .NET general concept dicussion (not help).
Was This Post Helpful? 0
  • +
  • -

#6 sha1023012  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-July 11

Re: How to create a HTML editor im having a problem

Posted 14 July 2011 - 09:02 PM

Well someone said I had this in the wrong part?
So does anyone know if there is any videos or other webpages to help me here?
Was This Post Helpful? 0
  • +
  • -

#7 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 209
  • View blog
  • Posts: 1,365
  • Joined: 16-March 11

Re: How to create a HTML editor im having a problem

Posted 15 July 2011 - 12:29 AM

You could always use a webbrowser control, change it's visible property to false, load a page, and grab the WebBrowserCtrl1.DocumentText, and display it in a textbox.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub

    Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
        RichTextBox1.Text = WebBrowser1.DocumentText.ToString
    End Sub



Little example there.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1