FOpenForm File Open wwwwwwwwwp wwwwwwwwwp wwwwwwwwwp Form1* Text1 FileName Command1 &Open FNameLabel File &Name: Label4 Directory: Label1 Label1 Command2 &Cancel FilesLabel &Files: DirLabel &Directories: File1 List1 TheFocus List1Flag@ Text1Flag TheDriveI LastChange Form_Load FormTitle> FOpenForm caption7 ThePath File1 ThePattern Pattern Text1b Textr Label1 Form_GotFocus| List1 List1_GotFocus GetFocus SendMessageY LB_DIR BuildSpec selstart sellength visible List1_Dblclick Listindex curnt OldPath ChangeDrive ErrState LB_RESETCONTENT List1_KeyPress} KeyAsciik File1_Click FileName File1_KeyPress File1_DblClick Command1_Click Text1_Keypress RemoveSpaces Listcount< TheFileNameV Foundit true7 false tempo ProcessEntry ChangeDir TheStructv OfStruct OpenFile OF_EXIST lclose FullName Text1_Change List1_Click TheText Command2_Click fpath Text1_GotFocus TextLimit EM_LIMITTEXT CompleteName ErrCodeK DirLabel_Click Label4_Click You are welcome to use FOPEN in your programs free of charge." If you make any improvements send me a copy at CIS-MAL 73667,1755e Costas Kitsosn Handle for Drive/Subdirectory ListBox Flag for Drive/Subdirectory ListBox 0 or 1M Flag for EM_LIMITTEXT The selected driveE Flag used when processing selectionsM Form_Load Set the flags for List1 and Text1 e Update Drive/Subdirectory listbox Limit text length r If the Parent didn't specify a FormTitle use the one that's built in. File Open" otherwise honor the Parent's specifications If there is a path specification use it, otherwise use the default. If the Parent specified a new pattern then use it. Finish up loading the form. Form_GotFocus Set the Focus on List1 to fill the ListBoxh List1_GotFocus get the handle of the ListBox fill it with the Drive/Subdirectory listing update the flag so we don't go through this every timeo highlight Text1 List1_Dblclick List1 holds both drives and subdirectoriess get the current selectione save the old path in case of error if the user chose a drive parse it and change to it if the user chose a subdirectory change to it LB_RESETCONTENT clears the list fastn LB_DIR specifies the type of listbox, &HC010 specifies drives and subdirectories only.l if there was an error let the user know.C List1_KeyPress if the user presses the Return key while on a valid entry, invoke a List1_DblClickn File1_Click update the textbox and the lastchange flagn File1_KeyPress if Return, select File1_DblClickh File1_DblClick Good, we have a file, let's tell Command1 Text1_Keypress process whatever the user typed in Text11 get rid of the beep (Mark, thanks for the tip)t remove any space characters. Some users put a space after a period out of habit. see if the file is in File1.List. If it is, we're done so let's tell Command1.i if the file is not in File1.List let's see what the user is trying to do. drive? subdirectory? wildcards? flag used by ChangeDrive if we found a drive change to it If changing to the drive didn't cause any errors or if a drive wasn't specified if a subdirectory was specified newd$ holds everything to the left of the last backslash tempo$ hold the rest. Now, process them. did the user specify only a new pattern?. highlight the text ChangeDrive try to change to the new drivew if an error occurred go back to the way things were change the flag so Text1 knows ChangeDir change to the new directory and update List1g you may add a MsgBox error message here if you think it's necessary.y ProcessEntry we'll use this if/when we have to use OpenFile if a$(newd$) isn't empty change to it.O if b$(tempo$) isn't empty let's see what it could be. if it's a new pattern then let File1.List know otherwise could it be a file? use OpenFile to see if it exists. If so x% will return a file handle. This is a very useful API function.I close the file if we have a file handle, we're done let's tell Command1 no handle? The user probably specified a subdirectory. Text1_Change needed by Command1 Command1_Click process Text1 entryT we have a file, put together the FullNamei let List1 know we have a file and a FullName we have a file, put together the FullName List1_Click let Command1 know RemoveSpaces squeezes out spaces Command2_Click ' did the user press cancel? Change FullName into an empty string so the Parent knows.n BuildSpec builds the spec for SendMessage Text1_GotFocus Do this only once send the message to limit the text entry to not more than 127 characterse