Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message of the day

Status
Not open for further replies.

bevan

Programmer
Jan 11, 2001
22
0
0
GB
Hi all,
I want to read a random line of text onto the top of my page as a message of the day. I was hoping to just be able to store them in a .txt file or something simple like that, but if it has to be a db then that is no problem.
Whenever a user goes to my page they will then get a new message.
Has anyone done this before or know of a suitable way?

Thanks,

The Don
 
It can be done both ways.

If you use a flat text file for your messages, you'll need to create a File object from the Scripting Runtime Library.

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile('C:\MyFile.txt')
txtStream = objFile.OpenAsTextStream(1, 0)

Then you parse the text from the textStream into an array, select your random quote, and you're set.

If you use a database, you'll probably use an Access database file and ADO. Create a database table with an integer primary key and a text field for your messages. Then you just generate your random number and do a SQL select from the database where the primary key = your random number.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top