Results 1 to 4 of 4

Thread: Please try to fix this!

  1. #1

    Thread Starter
    Hyperactive Member Asaf_99's Avatar
    Join Date
    Jul 2000
    Location
    Israel
    Posts
    335

    Unhappy

    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.
    Asaf Sagi

    ICQ: 61917199
    E-Mail: [email protected]

  2. #2
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    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!]

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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

  4. #4

    Thread Starter
    Hyperactive Member Asaf_99's Avatar
    Join Date
    Jul 2000
    Location
    Israel
    Posts
    335

    Wink

    ThanX for your help, it works just fine!
    Asaf Sagi

    ICQ: 61917199
    E-Mail: [email protected]

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