|
-
Nov 26th, 2000, 11:06 PM
#1
Thread Starter
Junior Member
Well the title says most, and i thank everyone who helped me with my last problem. But right now i was working on creating my own small wanna-be notepad. But when i use the function:
Form1.CommonDialog1.Filter = "Text Files (*.TXT)|*.TXT|All Files (*.*)|*.*"
Form1.CommonDialog1.ShowSave
Form1.RichTextBox1.SaveFile (Form1.CommonDialog1.FileName)
Form1.Caption = Form1.CommonDialog1.FileName & ""
Then save through that it gives you all sorts of garbage before the text you really want is shown. An Example of what i mean. The text is suppose to be test, but it comes out like this:
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;}}
{\colortbl\red0\green0\blue0;}
\deflang1033\pard\plain\f2\fs17 --> test <--
\par }
I went and tried to look for other examples but they were using things like
cd1.ShowSave
And stuff like that, and when i searched through the code it had nothing declaring cd1.
Please help, thanks!
Dreys
"Your worst enemy is your greatest teacher."
-
Nov 26th, 2000, 11:21 PM
#2
Frenzied Member
Looks like it's saving it as rich text rather than plain text. If you open up a rich text file that you've made with just the text "Test" in it then I'll bet that would give you almost if not completely identical results.
I don't know much about the common dialog, so all I can say is make sure you're using plain text and not rich text.
Harry.
"From one thing, know ten thousand things."
-
Nov 27th, 2000, 12:28 AM
#3
transcendental analytic
cd1 is probably the commondialog control which is what you leaved named CommonDialog1, use that name instead.
Also to make the cancel button work, you need to activate the cancelerror, set it to true in the commondialog properties. Then make a simple error handler for it
Code:
on error resume next
If Me.Parent = Nothing Then
with form1
.CommonDialog1.Filter = "Text Files (*.TXT)|*.TXT|All Files (*.*)|*.*"
.CommonDialog1.ShowSave
if err then exit sub'or function or whatever
.RichTextBox1.SaveFile (Form1.CommonDialog1.FileName)
.Caption = Form1.CommonDialog1.FileName & ""
end with
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 27th, 2000, 02:44 AM
#4
Addicted Member
More formats - more power
You can save the contents of your rich textbox in two different formats:
a) with formatting (bold, different sizes, colors, etc.)
b) Straight forward normal boring old text (like notepad)
The SaveFile method has two parameters. The first is the filename of the file you are saving, and the second specifies in which of the two formats you want to save your file. Since you do not specify the second parameter, it defaulted to RTF format, which gave you all the garbage you saw.
So basically, there is nothing wrong with the way you are using the common dialogue control. Try this instead:
Code:
'For normal text
RichTextBox1.SaveFile (Form1.CommonDialog1.FileName, rtfText)
'For formatted text
RichTextBox1.SaveFile (Form1.CommonDialog1.FileName, rtfRTF)
When you save normal text, your file should be saved as .txt, but when you save with formatting, be sure to use the .rtf extension.
You can make your program better than Notepad, by allowing the user the choice of formatted or non-formatted text.
Hope this helps.
Shrog
-
Nov 27th, 2000, 09:11 PM
#5
Thread Starter
Junior Member
Cool thanks a lot for the help!
Dreys
"Your worst enemy is your greatest teacher."
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
|