|
-
Aug 27th, 2000, 05:19 PM
#1
Thread Starter
Hyperactive Member
I have this:
Code:
Private Sub mnuLoad_Click()
lstDeck.Clear
Open App.Path & "\Decks\" & txtTitle.Text & ".dck" For Input As #1
Do While Not EOF(1)
Line Input #1, tmp
lstDeck.AddItem tmp
Loop
Close #1
stbStatus.Panels(2).Text = "Cards In Deck: " & lstDeck.ListCount
End Sub
I want to do that whenever the app detects that the file written on txtTitle does not exist, it will show me a message box and not terminate the app.
Could you please modify this code and not using Text1. etc. because I get confused.
Every help will be appriciated.
-
Aug 27th, 2000, 05:23 PM
#2
Fanatic Member
Private Sub mnuLoad_Click()
on error goto 1000
lstDeck.Clear
Open App.Path & "\Decks\" & txtTitle.Text & ".dck" For Input As #1
Do While Not EOF(1)
Line Input #1, tmp
lstDeck.AddItem tmp
Loop
Close #1
stbStatus.Panels(2).Text = "Cards In Deck: " & lstDeck.ListCount
exit sub
1000 msgbox "HEY THAT FILE DOES NOT EXIST"
close #1
End Sub
-----------------------
or
Private Sub mnuLoad_Click()
lstDeck.Clear
if dir(App.Path & "\Decks\" & txtTitle.Text & ".dck")="" then msgbox "hey that does not exist!":exit sub
Open App.Path & "\Decks\" & txtTitle.Text & ".dck" For Input As #1
Do While Not EOF(1)
Line Input #1, tmp
lstDeck.AddItem tmp
Loop
Close #1
stbStatus.Panels(2).Text = "Cards In Deck: " & lstDeck.ListCount
End Sub
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 27th, 2000, 10:29 PM
#3
_______
<?>
Code:
Private Sub command1_Click()
Dim sFile$
'sFile = "Name And Path Of Your File"
sFile = App.Path & "\Decks\" & txtTitle.Text & ".dck"
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(sFile$) = True Then
lstDeck.Clear
Open App.Path & "\Decks\" & txtTitle.Text & ".dck" For Input As #1
Do While Not EOF(1)
Line Input #1, tmp
lstDeck.AddItem tmp
Loop
Close #1
stbStatus.Panels(2).Text = "Cards In Deck: " & lstDeck.ListCount
Else
MsgBox "Does Not Exist...Your code here!"
End If
Set fs = Nothing
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 28th, 2000, 05:11 AM
#4
Thread Starter
Hyperactive Member
ThanX for your help, it works just fine!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|