Results 1 to 4 of 4

Thread: using same DriveListBox for multiple uses?

  1. #1

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    using same DriveListBox for multiple uses?

    On my form I have a DriveListBox, DirListBox, FileListBox, two text fields, txtFile1 and txtFile2 and two picture boxes Picture 1 and Picture 2. What I want to do is use the same controls to load a jpg image into picture1 and another jpg image into picture2. I have my controls to setup to load my image into picture1. How do I reset the controls so I can add another image into Picture2?

    VB Code:
    1. '//////////// SELECT FOLDER FROM DRIVE //////////////////////
    2. Private Sub Drive1_Change()
    3.     Dir1.Path = Drive1.Drive
    4. End Sub
    5.    
    6.     '//////// SELECT DRIVE LETTER FROM LOCAL HARD DRIVE /////////////////
    7. Private Sub Dir1_Change()
    8.     File1.Path = Dir1.Path
    9. End Sub
    10.  
    11.     '/////////// PUT FILE NAME INTO TEXT BOX
    12. Private Sub File1_Click()
    13.     Dim txtPath$
    14.     txtPath$ = Dir1.Path
    15.     If Mid(txtPath$, Len(txtPath$), 1) = "\" Then
    16.         txtFile1.Text = Dir1.Path & File1.FileName
    17.     Else
    18.         txtFile1.Text = File1.FileName
    19.     End If
    20.    
    21.    Picture1.Picture = LoadPicture(Dir1.Path & "\" & File1.FileName)
    22.        
    23. End Sub
    He who never made a mistake never made a discovery?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: using same DriveListBox for multiple uses?

    Create a Boolean. If the boolean is true, then Picture1 already has a picture, load it into Picture2.

  3. #3

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: using same DriveListBox for multiple uses?

    Thanks for the quick reply, I made a global bolean called "bolsmallPhoto" and I also made to global varibles smPhoto and lgPhoto as Strings. When my form loads I set the bolsmallPhoto = false. I then changed my code to this, and so far everything is working.

    What I want to know now is, when I select the small photo and it is correct, I need the file1.list box to clear itself. I tried File.Refresh, but that doesn't really clear the box out. How can I do that?

    VB Code:
    1. Private Sub File1_Click()
    2.     Dim txtPath$
    3.     txtPath$ = Dir1.Path
    4.     Dim Msg   ' Declare variable.
    5.    
    6.            If bolsmallPhoto = False Then
    7.                 If Mid(txtPath$, Len(txtPath$), 1) = "\" Then
    8.                     txtFile1.Text = Dir1.Path & File1.FileName
    9.                 Else
    10.                     txtFile1.Text = File1.FileName
    11.                 End If
    12.                     Picture1.Picture = LoadPicture(Dir1.Path & "\" & File1.FileName)
    13.                      Msg = "Is this small photo correct?"
    14.                         If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbYes Then
    15.                             smPhoto = Dir1.Path & "\" & File1.FileName
    16.                             bolsmallPhoto = True
    17.                             txtFile2.Visible = True
    18.                             Picture2.Visible = True
    19.                             Label2.Visible = True
    20.                             File1.Refresh
    21.                         Else
    22.                             bolsmallPhoto = False
    23.                             Exit Sub
    24.                         End If
    25.        Else
    26.                 If Mid(txtPath$, Len(txtPath$), 1) = "\" Then
    27.                      txtFile2.Text = Dir1.Path & File1.FileName
    28.                 Else
    29.                      txtFile2.Text = File1.FileName
    30.                 End If
    31.                      Picture2.Picture = LoadPicture(Dir1.Path & "\" & File1.FileName)
    32.                      Msg = "Is this large photo correct?"
    33.                         If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbYes Then
    34.                             lgPhoto = Dir1.Path & "\" & File1.FileName
    35.                             File1.Refresh
    36.                         Else
    37.                             Exit Sub
    38.                         End If
    39.                        
    40.         End If
    41. End Sub
    He who never made a mistake never made a discovery?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: using same DriveListBox for multiple uses?

    Quote Originally Posted by Navarone
    What I want to know now is, when I select the small photo and it is correct, I need the file1.list box to clear itself. I tried File.Refresh, but that doesn't really clear the box out. How can I do that?
    The filelist box doesn't have a .Clear method like the listbox, so I'd suggest feeding it a pattern you know doesn't exist. Something like
    VB Code:
    1. File1.Pattern = ".xxx"

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