
Will Wordpad work will in vb4 32bit?
Quote:
> > > Hi,
> > > I programmed in qbasic4.5 a few years, now I have tried VB40.
> > > My first project and I have problems already.
> > > How can I, on a signal main form have a Dirlistbox on the left side
> > > of the form with 4 or 5 categories that are clickable linking to 10
to
> 15
> > > text files that show up in a FileListBox on the right side of the form
> that
> > > are clickable. When a file is clicked on wordPad opens and the text
file
> > > is viewable and readable on screen. After closing WordPad it returns
> > > control to my main form once again for another selection to read a
> > > text file. It May look something like this:
> > > EXAMPLE Of Form Layout
> > > ===========================================================
> > > How To Do Most Anything
> > > ------------ Categories -------- Text Files From each
> Category -----
> > > How To 1 (This one is clicked on) Text Files
> > > How To 2 Text
> Files
> > > How To 3
> TextFiles
> > > How To 4
> TextFiles
> ------------- ------------------------------------
> > > ===========================================================
> > > The Categories and the Text files will be placed in folders within the
> > > program folder.
> > > Program folder
> > > Category folder
> > > Textfile folder
> > > Any Help will be wonderfully appreciated and an honorable mention
> > > in the finished program. Thank you all.
> > > Tom
OK, let's break this down a little further, you would need 3 boxes on the
left side to upply a full list, a DriveList Box, A DirectoryList Box and a
File List Box. Assuming they are Drive1, Dir1 and File1 the following code
will handle keeping them in sync with each other.
Private Sub Drive1_Change()
Dim Bombed As Integer
Static DriveStack As String
' Error check here
Bombed = False
On Local Error GoTo BadDrive
Dir1.Path = Drive1.Drive
' Trap attempted changes to empty floppy & CD-ROM drives
If Bombed Then
MsgBox "Drive " & Drive1.Drive & CR & _
" is not currently available" & CR & _
"Drive change request ignored.", _
vbOKOnly + vbExclamation, _
"Drive Not Ready Warning"
Drive1.Drive = DriveStack
Else
DriveStack = Drive1.Drive
End If
On Local Error GoTo 0
Exit Sub
BadDrive:
Bombed = True
Resume Next
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Dir1_KeyPress(KeyAscii As Integer)
' Allows directory selection by pressing ENTER as
' well as mouse click
If KeyAscii = 13 Then
Dir1.Path = Dir1.List(Dir1.ListIndex)
KeyAscii = 0
Dir1.SetFocus
End If
End Sub
Now for the second part you need to open the clicked file in word pad ...
Private Sub File1_Click()
If File1.ListIndex < 0 Then Exit Sub
' Coded "On the fly" I believe the "\" is needed,
' but it may not be. Off the top of my head I
' can't remember for certain if Dir1.Path normally ends
' with the backslash or not, I don't think it does.
Shell "Wordpad.exe " & Dir1.Path & "\" & File1.List(File1.ListIndex)
End Sub
Private Sub File1_KeyPress(KeyAscii As Integer)
' Allows file selection by pressing ENTER on
' the highlighted list item.
If KeyAscii = 13 then
KeyAscii = 0
File1_Click()
End If
End Sub
Alternately you may want to change the references to File1_Click to
File1_DblClick instead. This more closely matches the behavior people
expect
in a windows application.
I hope this is some help.
Best,
Bill
--
--------------------------------------------------------
Due to excessive spam and being tired of redoing my mail
filters every week I now post to newsgroups with a bogus
username in my e-mail address. To reach me make it