Jump to content
xisto Community
Sign in to follow this  
iXeta

Create Dynamic Html/php Pages Using Simple Vb.net Code Taking your application data, and creating a webpage for others to vie

Recommended Posts

This example will show you how use a string in VB to create PHP code.

In order to do this, you need a string to store your PHP page and

a function that I will list at the bottom of the page for you to put in

a module. This code is written in VB.NET

 

Public Sub CreatePage(ByVal HTMLTitle As String, ByVal HTMLText As String, ByVal HTMLFileName As String)

Dim strFile As String

 

' ----------------------

' -- Prepare String --

' ----------------------

strFile = ""

 

' --------------------

' -- Write Starter --

' --------------------

strFile = "<html>" & vbNewLine

strFile = strFile & "<head>" & vbNewLine

strFile = strFile & "<title>" & HTMLTitle & "</title>" & vbNewLine

strFile = strFile & "</head><body>" & vbNewLine

strFile = strFile & HTMLText & vbNewLine

strFile = strFile & "</body></html>"

SaveTextToFile(strFile, "C:\" & HTMLFileName & ".html")

 

End Sub

 

'///////////////////////////////////////////////////////////////////////////

'// Call this sub using: Call CreatePage("Welcome", "Hello world! This is a dynamic page.", "index")

'///////////////////////////////////////////////////////////////////////////

 

---------------------------------------------------------------------------

Okay! Now we're done with the sub for creating the page, this is the

only other snippet of code you will need, this needs to go into a

module of your program.

---------------------------------------------------------------------------

 

 

Public Function SaveTextToFile(ByVal strData As String, _

ByVal FullPath As String, _

Optional ByVal ErrInfo As String = "") As Boolean

 

Dim Contents As String

Dim Saved As Boolean = False

Dim objReader As IO.StreamWriter

Try

 

 

objReader = New IO.StreamWriter(FullPath)

objReader.Write(strData)

objReader.Close()

Saved = True

Catch Ex As Exception

ErrInfo = Ex.Message

 

End Try

Return Saved

End Function

 

---------------------------------------------------

As you can see, the code has a wide range of uses,

such as taking old INI databases from your applications

and being able to turn them into a useable webpage.

Just take the strFile and add onto it with any HTML code

or even PHP, all you'd have to do is change the ending

on the save function inside the CreatePage sub.

 

Right now I'm working on a program that takes a simple

INI database, a couple arrays, and I'm able to make

a program that updates an online roster with the click

of a button. So instead of copying and pasting 800 times

I'm going back to gaming for an hour.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.