Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 4th, 2004, 11:48 AM   #1
madhattertcm
Newbie
 
Join Date: Sep 2004
Posts: 2
Rep Power: 0 madhattertcm is on a distinguished road
Heres what I'm wanting to do. Theres a certain part of the HTML file where all the text is..I want a vb program to be able to open that part of the text and edit it, and place it back into the html file..

Get what I'm saying?

Thanks
madhattertcm is offline   Reply With Quote
Old Sep 4th, 2004, 3:28 PM   #2
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 5 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
hmm maybe you could somethign with like a place holder, to sort of make a template in a way.

e.g.


Template.html

<html>
<body>
{TEXT}
</body>
</html>

And then the program could open up the templace file, and just replace the {TEXT} with the actual text and then resave it as the real HTML page.
thechristelegacy is offline   Reply With Quote
Old Sep 7th, 2004, 9:22 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
What i would do is have a set of html comments, one for the start of the text area and one to end it. Then just have the vb code search for these strings (the html comments) and throw the text in between the comments. So your html file would llook somthing liek this:

<html>
<head>
<body>
<!--start of text-->
Your text goes here.
<!--end of text-->
some text that you don't want to ever change.
</body>
</html>
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Sep 7th, 2004, 10:31 PM   #4
madhattertcm
Newbie
 
Join Date: Sep 2004
Posts: 2
Rep Power: 0 madhattertcm is on a distinguished road
the HTML part is easy, I know how to do that.
But I don't know how to get say a textbox in VB to
search for that particular part of the html document
madhattertcm is offline   Reply With Quote
Old Sep 8th, 2004, 11:11 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
The text box doesn't search the file - your code does.

First, open the file for reading. Then parse it, line by line, into a string array, checking each one for the starting comment as you go. When you reach the comments, make a note of the line number. Then parse the bits between the comments, but don't save it into the array. When you reach the ending comment, start saving it again, until you reach the end of the file.

Next, open the file for output. Until you get to the comment (you stored the line number earlier), just output the string line by line. When you do, output the stuff you want. Then send the bottom bit (the ending comment onwards). And voila! You're done!

I realise you might not know how to do some (or any) of this. If there's anything you need help with, please post back.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 10th, 2004, 11:34 AM   #6
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Herečs a function that will return the text between your two markers.



function grabtext(filename, search as string) as variant

dim check as boolean
dim text() as string
dim tmp() as string
dim read as string
dim y, x as integer

read = Space(FileLen(filename))
Open filename For Binary As #1
  Get #1, 1, read
Close #1

tmp() = Split(read, vbCrLf)

check = false

y = 0
x = 0

for x=0 to UBound(tmp)
    if (tmp(x) == search) then
        check = true
    else
        check = false
    end if
   
    if (check = true) then
        text(y) = tmp(x)
        y = y + 1
    end if
Next x
   
return text()

end function


Anyways, this code has not been tested yet at all, so there could be bugs in it. Good luck.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Sep 10th, 2004, 4:15 PM   #7
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
I'll run it through the garden this weekend... I think I may have a use for something similar.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Sep 13th, 2004, 10:03 AM   #8
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Has anybody tested that code? i will somtime today if need be.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:40 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC