![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2004
Posts: 2
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Expert Programmer
|
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. |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Sep 2004
Posts: 2
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() |
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 functionAnyways, 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! |
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|