Results 1 to 8 of 8

Thread: text editor: open dialog [resolved]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    text editor: open dialog [resolved]

    I'm really new to VB, I started about two weeks ago in a class at school, but here goes:

    I'm using VB 6.0, and I'm making a text editor, and I have it working fine at this point. I use a drive selector, directory box, and file box to determine what files to open. I want to have you able to click on a button labelled "open" and it will pop open a browse window, and allow you to look around your computer for an appropriately labelled file type. I think you have to make a "CommonDialog" but I'm not sure how to make one, and I'm not sure if that's even what you have to make. I was looking through a post last night and found some stuff on ListBoxes and I took some of the code there to come to making this:

    VB Code:
    1. Private Sub menu_open_Click()
    2.   CommonDialog1.Filter = "PHP (*.PHP;*.PHP3;*.PHTML;*.TXT) | *.php;*.php3;*.phtml;*.txt"
    3.   CommonDialog1.CancelError = False
    4.   CommonDialog1.ShowOpen
    5. End Sub

    So, does anyone know how to make a CommonDialog? Or a better way of doing what I want to do?
    Last edited by kows; Sep 14th, 2003 at 06:15 PM.
    Like Archer? Check out some Sterling Archer quotes.

  2. #2
    Lively Member morrowasted's Avatar
    Join Date
    Aug 2003
    Location
    Houston, TX
    Posts
    118
    just search through your controls for "Microsoft Common Dialog Control" and paste it on your form anywhere (it is invisible during runtime), and that should work for you!

    -morrowasted

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    I have no idea how to "search through my controls." I searched through the object browser for that and just plain "CommonDialog" and it couldn't find anything. I'm new to VB, so I don't really know that much about it except most of the basics, but I am a web programmer.

    edit: nevermind, I figured out how to add the common dialog, but I get an error when I try to run the program. I selected the commondialog thing, pressed ok, and ran it and it gave me an "Object Required" error here (highlighted red):

    VB Code:
    1. Private Sub menu_open_Click()
    2.      [COLOR=red]CommonDialog1.Filter = "PHP + TXT (*.PHP;*.PHP3;*.PHTML;*.TXT) | *.php;*.php3;*.phtml;*.txt"[/COLOR]
    3.      CommonDialog1.CancelError = False
    4.      CommonDialog1.ShowOpen
    5.      commonFile = CommondDialog1.FileName
    6.      If Len(commonFile) > 0 Then
    7.        OpenFile txt_file, commonFile 'show file contents
    8.        lbl_filepath.Caption = commonFile 'show filepath
    9.        menu_close.Enabled = True 'enable close button
    10.        menu_save.Enabled = True 'enable save button
    11.      End If
    12.    End Sub

    man, I'm such a VB newb..
    Last edited by kows; Sep 14th, 2003 at 04:37 PM.
    Like Archer? Check out some Sterling Archer quotes.

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Did you add a common dialog to the form? Check the name of it to make sure it is CommonDialog1.


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    I went to Projects > Components and scrolled down to 'Microsoft Common Dialog Control 6.0' and pressed the checkbox next to it, and then hit OK. It doesn't show up as an object in my form, like under the drop down menus, so I have no idea if I actually added it.

    Any help is appreciated..
    Like Archer? Check out some Sterling Archer quotes.

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    It will show up in the ToolBox. You need to add one just like the way you add textboxes, command buttons or labels


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    ahh, cool, thanks then. How simple of a mistake that screwed me up, I never would of thought it would add into my tool box. Thanks again.
    Like Archer? Check out some Sterling Archer quotes.

  8. #8
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    No problem Just so you know, everything you add from the components list goes to your toolbox and you have to add it to a form.


    Has someone helped you? Then you can Rate their helpful post.

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