help me please, i am designing an html editor, i want to know how i can save text1.text as an html file through the save dialog box
Printable View
help me please, i am designing an html editor, i want to know how i can save text1.text as an html file through the save dialog box
Do this:
1: Place the common dialog control and a command button on your form and use the following code.
Hope that helps.Code:Private Sub cmdSave_Click()'cmdSave being the name of your command button
Dim CDialog As cCommonDialog
Set CDialog = New cCommonDialog
CDialog.Filename = Filename
CDialog.Filter = "HTML |*.html*"
CDialog.ShowSave
FilePathName = CDialog.Filename
If CDialog.Filename = "" Then Exit Sub
End If
End Sub
Close Stephen Bazemore.
Code:Private Sub cmdSave_Click()
Dim iFile As Integer
On Error GoTo User_Cancelled
With CommonDialog1
.CancelError = True
.DialogTitle = "Save..."
.Filter = "HTM Files (*.htm)|*.htm"
.ShowSave
iFile = FreeFile
If .filename = "" Then Exit Sub
Open .filename For Output As iFile
Print #1, Text1.text
Close iFile
End With
User_Cancelled:
End Sub
aww man.. i was feeling all good about helpin him.. now you gotta blow it for me.. :) haha. Well mine works, but yours is better. So go with matthews.
"Because matthew is Always right."
Yours is just the same Steven, I only added things. And a few other stuff :rolleyes:.
I was just jokin around. :p
here is my version, it says in the dialog box in the save as type box "html File (*.html) but if i dont actully name the file blahblah.html it tells me it doesnt exist and crashes... here is code
Private Sub Command1_Click()
Screen.MousePointer = vbNormal
Dim nFile%
Dim vDummy$
CommonDialog1.Action = 2
Screen.MousePointer = vbHourglass
nFile% = FreeFile
Open CommonDialog1.FileName For Output As #nFile
Print #nFile, Text1.text
Close #nFile
Screen.MousePointer = vbNormal
End Sub
err.. Why not just use the code Matthew posted and add the
andCode:Screen.MousePointer = vbNormal
to it?Code:Screen.MousePointer = vbHourglass
Because if your saving the file "nFile" then it will already be in your textbox, so why do you need to re-print it into it? correct me if i'm wrong, but that's how I see it.
someone gave me that code, i knew it was wack, ill try his
what should i put in the filter properties of the dialog so i just type a name and it says as an html file
i know i can keep the same dialog box, but how would i load the html into text1.text
Quite easy as well. This will read it into a text file:
Code:Private Sub cmdOpen_Click()
Dim iFile As Integer
On Error GoTo User_Cancelled
With CommonDialog1
.CancelError = True
.DialogTitle = "Select a HTM File.."
.Filter = "HTM (*.htm)|*.htm"
.ShowOpen
iFile = FreeFile
If .filename = "" Then Exit Sub
Open .filename For Input As iFile
Text1 = Input(LOF(iFile), iFile)
Close iFile
End With
User_Cancelled:
End Sub
you guys are helping out bigtime, i ill test this: how do i put in another filter, a new pair of quotes? and does that make the drop down list longer? now here is the inportant question:
how do i make a preview button so when clicked, the file opens in internet explorer? i know it has somthing to do with temporery files, and, how at the end, it delets the temp
on this part of the code, it highlighted input and said could not find project or library
Text1 = Input(LOF(iFile), iFile)
thanks you guys, i will prob have more questions, but i just started vb class 4 weeks ago, and before that i had no expierience with that, i was dimming things before the teach told us about that, he asked me if i read the book, i said no, i went online and learned some vb script, this other kid in the class, he has chunky soup dandruff, really nasty ****, i just ate, so i wont talk about it, he is good, but he cant do **** on his comp cuz its 100 mghz, i have got to be teh most advanced kid in that class, now along with internet applications, i also "<i>own</i>" this class to, could you guys explain what each part of these codes do, or point me to a really good guide? this html is gonna be wicked sweet soon, im gonna convert all my buttons to graphical, using fireworks: coold 3d 1, and 3, and paint shop pro 7, all of which i downloaded for free: thanks warez, anyway, is there a way to put flash into a program, and just make the program a shell for flash?
is this the code:
its still highliting the input and saying library not foundCode:
Dim iFile As Integer
On Error GoTo User_Cancelled
With CommonDialog1
.CancelError = True
.DialogTitle = "Select a HTM File.."
.Filter = "HTM (*.htm)|*.htm"
.ShowOpen
iFile = FreeFile
If .FileName = "" Then Exit Sub
Open .FileName For Input As #1
Text1 = Input(LOF(1), 1)
Close #1
End With
User_Cancelled:
Q1: Do you have this line anywhere in your project? Option Explicit
Q2: What version of VB are you using?
i have vb 2.0 and chipmunk basic: j/k i have visual studio 6.0
,ill put option explicit in
You don't really need Option Explicit.
But try this instead of Input, try using Binary.
Code:Open .FileName For Binary As #1
start$ = 1
buffer1$ = String$(10000, 0)
Get #1, start$, buffer1$
Text1.Text = Text1.Text & buffer1$
Close #1
ill try it, are you telling me you know binary as well, holy crap dude, do you know it pure? and how would you write a program in total binary
the preview has a bug, it only loads the html thats in the body part of my code, and if i dont have any html when i preview, it crashes, i can fix that with a msgbox but how do i make it load the head of the html also
0100001001101001011011100110000101110010011110010010000001100001011100110010000001101100011010010110 101101100101001000000111010001101000011010010111001100111111
CONVERTED: Binary as like this?
(Sorry about the skipping...bugs!)
I need a little more information, are you using the Webbrowser (IE) Control as a reference?
If you don't like this way, you could always save it to your app's directory and load it through IE.
^This way would take up less resources :rolleyes:.Code:Private Sub cmdPreview_Click()
Open App.Path & "\preview.htm" For Output As #1
Print #1, Text1.Text
Close #1
DoEvents
If Dir(App.Path & "\preview.htm") <> "" Then
Shell (App.Path & "\preview.htm")
Else
MsgBox "Error: Preview file missing!", vbCritical
End If
End Sub
ill try this way with the temp file, i wanted to know what program you write binary in, like visual basic? anyway, i realyl dont care, i dont need to learn binary... do i?
lol, could you point me to a really good online tutorial for VB?
For tutorials and stuff for VB, you should stick to these sites:
http://www.vb-world.net
http://forums.vb-world.net
http://www.planet-source-code.com
http://www.vbapi.com
http://www.allapi.net
If you stick to these sites, you will learn much.
And you don't really need to know that kind of Binary to program in VB.
Good luck! :rolleyes:
i showed the code for that to my teach today (i keep getting an automation error when i click preview) and as usal he said , uuuuuhhhh lemme consult the book, he kept the code, and hid it! at the end of class i found it in his folder and took it back, what a loser! thanks for your help
What code? The Preview one? That should work. Maybe your missing some files or something?Quote:
he kept the code, and hid it! at the end of class i found it in his folder and took it back, what a loser! thanks for your help
No, you don't need to learn binary for now, however, you will need to learn some when you get into lower level languages.Quote:
Originally posted by kuker
[B]i dont need to learn binary... do i?/B]