Results 1 to 7 of 7

Thread: [RESOLVED] How do I use CommonDialog???

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Location
    Ngorno
    Posts
    70

    Resolved [RESOLVED] How do I use CommonDialog???

    Do I need to do something before I can use CommonDialog in my code.

    The below code doesn't work for me ... Error at CommonDialog

    VB Code:
    1. Private Sub MenuFile_Click(Index As Integer)
    2.  
    3. Select Case Index
    4.  
    5. Case 0 'Open
    6.  
    7. CommonDialog1.ShowOpen
    8.  
    9. Open CommonDialog1.FileName For Input As #1
    10.  
    11. Dim tmp() As String
    12. Dim Lines() As String
    13.  
    14. Lines = Split(Input(LOF(1), 1), vbCrLf)
    15. Close #1
    16. 'now you have each line in its own array element
    17. For x = 0 To UBound(Lines)
    18. tmp = Split(Replace(Lines(x), "//", ""), "/") 'This lines removes the // and then splits by /
    19. 'so now you have an array for the first line which is as follows
    20. 'tmp(0) = "Header1"
    21. 'tmp(1) = "info"
    22. 'tmp(2) = "moreinfo"
    23. 'tmp(3) = "yet some more"
    24. 'do what you need to
    25. Next
    26.  
    27. Case ...
    Last edited by Steff_DK; Sep 14th, 2005 at 01:47 PM. Reason: resolved

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How do I use CommonDialog???

    You may (at least) need to set Flags, Filter and assign file name to a string variable:
    VB Code:
    1. Private Sub Command2_Click()
    2. Dim strFile As String
    3.  
    4.     With CommonDialog1
    5.         .Flags = cdlOFNExplorer Or cdlOFNHideReadOnly
    6.         .Filter = "Text (*.txt)|*.txt"
    7.         .ShowOpen
    8.         strFile = .FileName
    9.         If Not strFile = "" Then
    10.             Open strFile For Input As #1
    11.                 'do something
    12.             Close #1
    13.         End If
    14.     End With
    15.  
    16. End Sub

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How do I use CommonDialog???

    You have to select it from the components list. Here is a quick sample of it use.

    http://vbforums.com/attachment.php?attachmentid=39609

  4. #4

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: How do I use CommonDialog???

    "It's cold gin time again ..."

    Check out my website here.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Location
    Ngorno
    Posts
    70

    Resolved [RESOLVED] How do I use CommonDialog???

    Thanks guys!

    Got it working

  7. #7
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: [RESOLVED] How do I use CommonDialog???

    This little app will show you all the functions of CommonDialog. It uses a RichTextBox to show the difference between loading a txt and rtf file.
    Attached Files Attached Files
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

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