|
-
Jul 25th, 2001, 11:56 PM
#1
Thread Starter
PowerPoster
Lots Of Help?
Sorry for all the questions!
1) How can i open a html file into a rich text box or normal text box? Is it the same as opening a text file? I want the code to show?
2) How can i then only show a specific bit/s of the code. So basically someone with no knowledge of web programming can come in and add text it etc.
3) Then save the file as filename.html overwriting the old one!!
Thanks for any help!
Beacon
-
Jul 25th, 2001, 11:59 PM
#2
Frenzied Member
open it using Open #1 as ...
and write it using Write
use Squencial (sp) or Binary Modes
-
Jul 25th, 2001, 11:59 PM
#3
Fanatic Member
I have never done it but i understand that a RTB can open and display an HTML document
As for addding text and then saving it back to html I would think you may have to parse the text back into html format to save it
I think i saw a control that did it somewhere
i will check for you
-
Jul 26th, 2001, 12:04 AM
#4
Opening and saving files with a rich text box is very easy
Opening:
RichTextBox1.LoadFile "c:\test.htm", rtfText
Closing:
RichTextBox1.SaveFile "c:\test.htm", rtfText
-
Jul 26th, 2001, 12:06 AM
#5
Fanatic Member
See I thought that it could be done with the RTB
The control I saw I think was for handling Html files without using the rtb just using OPEN FILE method
-
Jul 26th, 2001, 12:09 AM
#6
Thread Starter
PowerPoster
thanks ppl!
Howabout number 2??
thanks
-
Jul 26th, 2001, 12:12 AM
#7
I don't understand number 2 well enough to answer it..
You just want to show part of the file? What part?
-
Jul 26th, 2001, 12:15 AM
#8
Fanatic Member
you could use a second RTB and mid the section that you want to display out of the first RTB. Then join the two back together for saving
-
Jul 26th, 2001, 12:17 AM
#9
Thread Starter
PowerPoster
Basically what would be ideal would to be able to filter out all the code!!!!
And just have the text.
I.e Just have Hi how r u bl blah blah
Instead of all the tags and stuff around it!!
-
Jul 26th, 2001, 12:20 AM
#10
Fanatic Member
ah well you see thats what i was meaning with this control i saw it did that for you
damn I still trying to find where it was i saw it
-
Jul 26th, 2001, 12:26 AM
#11
Oh, I see. In order to do that' you need to get the text from the file into a string, here's how you can load from and save to a string. Both bits of code assume that sString is declared someplace else.
VB Code:
'Loading the text from the file
Dim FileNum As Long
FileNum = FreeFile
Open "c:\test.htm" For Input As FileNum
sString = Input(LOF(FileNum), FileNum)
Close FileNum
'Saving the text to the file
Dim FileNum As Long
FileNum = FreeFile
Open "c:\test.htm" For Output As FileNum
Print #FileNum, sString;
Close FileNum
By the way, if any of you are wondering why there's a semicolon at the end of one of the lines in the saving code, it's so the Print statement doesn't stick a newline at the end of the file.
I can post some code to strip off all the tags, but I don't see how it'd be useful. Do you know about the string manipulation functions VB provides? Basically, you gotta get creative with those.
I'll put together some code to strip off the tags right now, just as an example...
-
Jul 26th, 2001, 12:29 AM
#12
Fanatic Member
But even once the tags are stripped of you will still need to be able to format the text into the rtf properly
and then If changes are made he will have to reinsert the old tags and modify them to match any changes the user has made. Finally he will have to apply the approiate new tags to accomadate any new text and formatting that the user has applied and save it all back as a fully functioning HTML document.
-
Jul 26th, 2001, 12:40 AM
#13
Thread Starter
PowerPoster
hmm seems more complicated then i first thought! dammit!
-
Jul 26th, 2001, 12:41 AM
#14
Stripping off the tags isn't so useful, anyway. This is just an example of how the functions can be used. It should be easy enough to understand how to use this function:
VB Code:
Function StripOffTags(sString As String) As String
Dim LTPos As Long
Dim GTPos As Long
Dim sOut As String
LTPos = InStr(sString, "<")
GTPos = 1
Do Until LTPos = 0
sOut = sOut & Mid(sString, GTPos, LTPos - GTPos)
GTPos = InStr(LTPos, sString, ">") + 1
If GTPos <> 1 Then
LTPos = InStr(GTPos, sString, "<")
Else
Exit Do
End If
Loop
If LTPos = 0 Then
sOut = sOut & Mid(sString, GTPos)
End If
StripOffTags = sOut
End Function
If you try this on an html file, you'll see that the title gets left at the top of the text, <br> tags aren't converted to newlines, and there are many other things that aren't done. All this does is take out the tags.
-
Jul 26th, 2001, 01:05 AM
#15
Thread Starter
PowerPoster
thanks tygur
and rudvs2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|