Edit a HTML Template?

All you need is a Windows Form named Form1, with 3 textboxes and a button. You can name them the same as the button names I have, or change my button names, but this is all you need.

Code:
Imports System
Imports System.IO

Public Class Form1

    Private _htmlString As String = ""
    Private _imageHTML As String = ""
    Private _descriptionHTML As String = ""
    Private _postageCostHTML As String = ""

    Private Sub CreateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateButton.Click
        _imageHTML = "<img src=""" & Me.ImageUrlTextBox.Text() & """ alt=""My Product"" />"
        _descriptionHTML = "<p style="""">" & Me.DescriptionTextBox.Text() & "</p>"
        _postageCostHTML = "<span style="""">" & Me.PostageTextBox.Text() & "</span>"
        _htmlString = _imageHTML & Environment.NewLine() & _descriptionHTML & Environment.NewLine() & _postageCostHTML & Environment.NewLine()
        SaveFileDialog1.DefaultExt() = ".html"
        SaveFileDialog1.Filter = "HTML Files (*.html)|*.html|All files (*.*)|*.*"
        SaveFileDialog1.ShowDialog()
    End Sub

    Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
        Dim _stream As Stream
        _stream = File.Create(DirectCast(sender, SaveFileDialog).FileName())
        Dim sw As New StreamWriter(_stream)
        sw.Write(_htmlString)
        sw.Close()
        _stream.Close()
        Dim _res As MsgBoxResult = MsgBox("File Operation Complete, would you like to do another?", MsgBoxStyle.YesNo, "Complete")
        If _res = MsgBoxResult.Yes Then
            Me.DescriptionTextBox.Text() = ""
            Me.PostageTextBox.Text() = ""
            Me.ImageUrlTextBox.Text() = ""
        Else
            Me.Close()
        End If

    End Sub
End Class

Once you click the button, it grabs the things you've entered into the form fields, combines them into one, and writes and html file at a location of your choice.
 
Back
Top Bottom