Results 1 to 8 of 8

Thread: what am I doing wrong (small code)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I asked beofre, and someone gave me this code: (sorry I'm not sure who)

    Code:
    sfile = "C:\01.dat"
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    If FSO.fileexists(sfile) = True Then
    user32.Visible = True
    Form2.Visible = False
    Else:
    Form2.Visible = False
    Form1.Visible = True
    End If
    Set FSO = Nothing
    but everytime the code is processed, it always shows form1, even is the file does exsist
    NXSupport - Your one-stop source for computer help

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try explicitly hiding Form1:
    Code:
    Dim FSO As Object
    Dim sFile as String
    
    sFile = "C:\01.dat"
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    If FSO.fileexists(sFile) = True Then
        user32.Visible = True
        Form2.Visible = False
        Form1.Visible = False
    Else
        Form2.Visible = False
        Form1.Visible = True
    End If
    
    Set FSO = Nothing
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    sorry, it doesn't work. Also removed the 3 lines:

    else
    form2.visivle = false
    form1.visible = true




    and then it just stays on form2

    also I am 100% positive that the file exsists
    NXSupport - Your one-stop source for computer help

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Make sure that the file isn't System or Hidden.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I'm sure that its not hidden or anything
    NXSupport - Your one-stop source for computer help

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try this, using a different file:
    Code:
    Dim sFile As String
    Dim FSO As Object
    sFile = "C:\autoexec.bat"
    Set FSO = CreateObject("Scripting.FileSystemObject")
    If FSO.FileExists(sFile) = True Then
        Debug.Print "Exist"
    Else
        Debug.Print "Not exist"
    End If
    Set FSO = Nothing
    I'm not sure what's up with your other file, so see if it works with any other file.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Put a breakpoint in the Load event for Form2 and when it is displayed, examine the call stack to see how the event was triggered. I'll make a small bet that there is something in Form1 that is referring to some visible object on Form2, and anytime you do that, the form is shown.

  8. #8
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    What is User32? Is it a control on one of these forms? Also, you are setting Form2.Visible = False on both sides of the If/Else statement.
    "It's cold gin time again ..."

    Check out my website here.

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