Results 1 to 26 of 26

Thread: Saving files

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Exclamation

    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
    html, visual basic, and javascript, they all rule

  2. #2
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    Do this:

    1: Place the common dialog control and a command button on your form and use the following code.

    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
    Hope that helps.
    Stephen Bazemore
    Email:[email protected]

  3. #3
    Guest
    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

  4. #4
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    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."
    Stephen Bazemore
    Email:[email protected]

  5. #5
    Guest
    Yours is just the same Steven, I only added things. And a few other stuff .

  6. #6
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    I was just jokin around.
    Stephen Bazemore
    Email:[email protected]

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Arrow my version

    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
    html, visual basic, and javascript, they all rule

  8. #8
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    err.. Why not just use the code Matthew posted and add the
    Code:
    Screen.MousePointer = vbNormal
    and
    Code:
    Screen.MousePointer = vbHourglass
    to it?

    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.
    Stephen Bazemore
    Email:[email protected]

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Talking ummm

    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
    html, visual basic, and javascript, they all rule

  10. #10

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Question ok, to open files

    i know i can keep the same dialog box, but how would i load the html into text1.text
    html, visual basic, and javascript, they all rule

  11. #11
    Guest
    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

  12. #12

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Cool thanks

    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
    html, visual basic, and javascript, they all rule

  13. #13

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Exclamation error in open code

    on this part of the code, it highlighted input and said could not find project or library
    Text1 = Input(LOF(iFile), iFile)
    html, visual basic, and javascript, they all rule

  14. #14

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Exclamation wow

    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?
    html, visual basic, and javascript, they all rule

  15. #15

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Exclamation

    is this the code:
    Code:
     
        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:
    its still highliting the input and saying library not found
    html, visual basic, and javascript, they all rule

  16. #16
    Guest
    Q1: Do you have this line anywhere in your project? Option Explicit

    Q2: What version of VB are you using?

  17. #17

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Talking my version

    i have vb 2.0 and chipmunk basic: j/k i have visual studio 6.0
    ,ill put option explicit in
    html, visual basic, and javascript, they all rule

  18. #18
    Guest
    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

  19. #19

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Exclamation woa

    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
    html, visual basic, and javascript, they all rule

  20. #20

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Red face preview code

    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
    html, visual basic, and javascript, they all rule

  21. #21
    Guest
    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.

    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
    ^This way would take up less resources .

  22. #22

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Post ok

    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?
    html, visual basic, and javascript, they all rule

  23. #23
    Guest
    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!

  24. #24

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Talking thanks man

    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
    html, visual basic, and javascript, they all rule

  25. #25
    Guest
    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?

  26. #26
    Guest

    Re: ok

    Originally posted by kuker
    [B]i dont need to learn binary... do i?/B]
    No, you don't need to learn binary for now, however, you will need to learn some when you get into lower level languages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width