Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
question about directory list boxes
Old
  (#1)
Antony Clements
Guest
 
Posts: n/a
Default question about directory list boxes - 06-04-2007, 10:33 AM

i have written a program that incorporates the following code.

Private Sub Dir1_Change()
'changes the folder and displays each file in the folder
On Error Resume Next
File1.Path = Dir1.Path
RaiseEvent DirectoryChanged(Dir1.Path)
File1.Selected(0) = True
frmMain2.lblFileIn.Caption = Dir1.Path
frmMain2.lblFileOut.Caption = Dir1.Path
End Sub

is there any way i can modify this code to also work with a keypress event?

i have tried the following, but it doesn't work.

Private Sub Dir1_KeyPress(KeyAscii As Integer)
On Error Resume Next
If KeyAscii = vbKeyReturn Then
File1.Path = Dir1.Path
RaiseEvent DirectoryChanged(Dir1.Path)
File1.Selected(0) = True
frmMain2.lblFileIn.Caption = Dir1.Path
frmMain2.lblFileOut.Caption = Dir1.Path
End If
End Sub


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: question about directory list boxes
Old
  (#2)
J French
Guest
 
Posts: n/a
Default Re: question about directory list boxes - 06-04-2007, 10:33 AM

See inline :-

On Tue, 26 Dec 2006 11:38:01 +1100, "Antony Clements"
<EMAIL REMOVED> wrote:

>i have written a program that incorporates the following code.
>
>Private Sub Dir1_Change()
> 'changes the folder and displays each file in the folder
> On Error Resume Next
> File1.Path = Dir1.Path
> RaiseEvent DirectoryChanged(Dir1.Path)
> File1.Selected(0) = True
> frmMain2.lblFileIn.Caption = Dir1.Path
> frmMain2.lblFileOut.Caption = Dir1.Path
>End Sub
>
>is there any way i can modify this code to also work with a keypress event?
>
>i have tried the following, but it doesn't work.
>
>Private Sub Dir1_KeyPress(KeyAscii As Integer)
> On Error Resume Next
> If KeyAscii = vbKeyReturn Then

Dir1.Path = Dir1.List(Dir1.ListIndex) '<=== Add This ===
> File1.Path = Dir1.Path
> RaiseEvent DirectoryChanged(Dir1.Path)
> File1.Selected(0) = True
> frmMain2.lblFileIn.Caption = Dir1.Path
> frmMain2.lblFileOut.Caption = Dir1.Path
> End If
>End Sub


The highlighted Directory is NOT the selected Directory, that only
happens with a double click.

If I were you I would wrap this in a UserControl, it is the sort of
thing that you will probably want to re-use.



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: question about directory list boxes
Old
  (#3)
Antony Clements
Guest
 
Posts: n/a
Default Re: question about directory list boxes - 06-04-2007, 10:33 AM

thanks for that J French

"J French" <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED...
> See inline :-
>
> On Tue, 26 Dec 2006 11:38:01 +1100, "Antony Clements"
> <EMAIL REMOVED> wrote:
>
>>i have written a program that incorporates the following code.
>>
>>Private Sub Dir1_Change()
>> 'changes the folder and displays each file in the folder
>> On Error Resume Next
>> File1.Path = Dir1.Path
>> RaiseEvent DirectoryChanged(Dir1.Path)
>> File1.Selected(0) = True
>> frmMain2.lblFileIn.Caption = Dir1.Path
>> frmMain2.lblFileOut.Caption = Dir1.Path
>>End Sub
>>
>>is there any way i can modify this code to also work with a keypress
>>event?
>>
>>i have tried the following, but it doesn't work.
>>
>>Private Sub Dir1_KeyPress(KeyAscii As Integer)
>> On Error Resume Next
>> If KeyAscii = vbKeyReturn Then

> Dir1.Path = Dir1.List(Dir1.ListIndex) '<=== Add This ===
>> File1.Path = Dir1.Path
>> RaiseEvent DirectoryChanged(Dir1.Path)
>> File1.Selected(0) = True
>> frmMain2.lblFileIn.Caption = Dir1.Path
>> frmMain2.lblFileOut.Caption = Dir1.Path
>> End If
>>End Sub

>
> The highlighted Directory is NOT the selected Directory, that only
> happens with a double click.
>
> If I were you I would wrap this in a UserControl, it is the sort of
> thing that you will probably want to re-use.
>
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top