Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Latest VB Project


  • Please log in to reply

#1
amunra

amunra

    Member

  • Member
  • PipPipPip
  • 112 posts
Hi I am writing a web browser and am currently working on the favorites. I believe I need to write a new file for each page then have directory listing(?) list them under the Favorites menu. I have included a screen shot. Everything else works, this is the last thing I need to do. Actually I used my browser to write this post.

Thanks!!! :whistling:

Attached Thumbnails

  • screenshot.JPG

  • 0

Advertisements


#2
Phil

Phil

    IRC Chat Staff

  • IRC Chat Staff
  • 21 posts
Personally I'd use XML for that. You'd have something like...

<?xml version="1.0" encoding="UTF-8"?>

<favourites>
	 <category name="cat1" description="this is cat 1">
		 <item name="item1" description="this is item 1" url="http://www.item1.com/">
		 <item name="item2" description="this is item 2" url="http://www.item2.com/">
		 <item name="item3" description="this is item 3" url="http://www.item3.com/">
	 </category>
	 <category name="cat2" description="this is cat 2">
		 <item name="item1" description="this is item 1" url="http://www.item1.com/">
		 <item name="item2" description="this is item 2" url="http://www.item2.com/">
		 <item name="item3" description="this is item 3" url="http://www.item3.com/">
	 </category>
</favourites>

All stored in a single favourites file.

You can then parse it out (ideally with regex but you could do it with regular string functions also) and display it in your list.

~Phil~

Edited by Phil, 01 February 2007 - 01:55 AM.

  • 0

#3
amunra

amunra

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 112 posts
Very Cool!!! Thanks, but how do I add and remove from the file?
  • 0

#4
Phil

Phil

    IRC Chat Staff

  • IRC Chat Staff
  • 21 posts
To write to the file:

Dim sFileText as String
Dim iFileNo as Integer
iFileNo = FreeFile
'open the file for writing
Open "C:\Test.txt" For Output As #iFileNo
'please note, if this file already exists it will be overwritten!

'write some example text to the file
Print #iFileNo, "first line of text"

'close the file
Close #iFileNo

To read from the file:

	Dim intFileHandle As Integer
	Dim strRETP As String
	Dim fileContents as String
	intFileHandle = FreeFile
	Open "C:\Test.txt" For Input As #intFileHandle
	Do While Not EOF(intFileHandle)
		Line Input #intFileHandle, strRETP
		fileContents = fileContents & vbcrlf & strRETP
	Loop
	Close #intFileHandle

fileContents will = the contents of the file after the read code is done.

~Phil~

Edited by Phil, 02 February 2007 - 01:48 AM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP