Results 1 to 19 of 19

Thread: Can someone please help me

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Unhappy

    What I'm trying to make a regestration window come up only the first time the user runs this program. so can someone tell me what i'm doin wrong?

    Code:
    Private Sub Command1_Click()
    
    If fso.FolderExists("c:\dimas password\") Then
            Open "C:\dimas password\01.dat" For Output As #1
                Write #1, txtfn.Text, txtln.Text, txtcp.Text
            Close #1
                    Else:
                         MkDir "C:\dimas password\"
                         Open "C:\dimas password\01.dat" For Output As #1
                             Write #1, txtfn.Text, txtln.Text, txtcp.Text
                         Close #1
    
    End If
    End Sub
    
    Private Sub Form_Load()
    SetFormPosition Form1.hwnd, vbTopMost
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    If fso.filexists("c:\dimas password\01.DAT") Then
        Form1.Visible = False
        user32.Visible = True
    End If
    End Sub
    NXSupport - Your one-stop source for computer help

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

    1st part

    Public sfile

    Private Sub Form_Activate()

    'SetFormPosition Form1.hWnd, vbTopMost
    Dim FSO As Object

    sfile = "C:\dimas password\01.dat"

    Set FSO = CreateObject("Scripting.FileSystemObject")

    If FSO.fileexists(sfile) = True Then
    Form1.Visible = True
    user32.Visible = False
    Else
    Form1.Visible = False
    user32.Visible = True

    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Re: 1st part

    you know how you labeled it part one, is there a part 2? cause it doesn't work
    NXSupport - Your one-stop source for computer help

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Why use a Flat File? why not use the Registry, i.e.
    Code:
    Private Sub Form_Load()
        Dim sPassword As String
    
        sPassword = GetSetting(App.Title, "Settings", "Password", "")
        If Len(sPassword) Then
             'Password Found, Verify it...
        Else
             'Show Registration Form
             frmReg.Show vbModal
        Endif
    End Sub

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

    dimava

    I labeled it part 1 cause it is only the code from
    your form load event.

    I didn't look at the command button event because I figured
    if you loaded the proper form you could take it from
    there.

    I'm not sure exactly what you are after.
    the form load will load the user32 form if your password file doesn't exist and it loads form1 if the password file exists
    what do you want to happen?


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Re: dimava

    There is no password the 3 text boxes are:

    First name (txtFN)
    Last Name (txtLN)
    Company (txtCP)

    And the first time ever when the program starts, it asks for that information, and stores it in a file

    then when the program starts again (second time), it doesn't ask for that information again, cause its already stored, do you know what I mean? if not, I could reexplain my self.

    By the way the code that you gave me above doesn't, work, it always goes strait to the other form, (yes I have checked to make sure that I dont have those files on my hard drive)



    and to Aaron... Before I finish the program, I'm gonna put several layers of encyrption to it, and put it in the WINDOWS folder, and make it have a diffrent extension
    NXSupport - Your one-stop source for computer help

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

    ...ok..maybe I have your form names reversed

    I tested it before I posted it and I tested it again.
    it returned false and opened user32
    I add a folder..dinas passwords and saved 01.dat
    it returned true and opened form1

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Re: Re: ...ok..maybe I have your form names reversed

    Originally posted by dimava
    there is still something wrong, this is the code:

    Code:
    Public sfile
    Private Sub Command1_Click()
    
    
    'If FSO.FolderExists("c:\dimas password\") Then
            Open "C:\dimas password\01.dat" For Output As #1
                Write #1, txtfn.Text, txtln.Text, txtcp.Text
            Close #1
     '               Else:
     '                    MkDir "C:\dimas password\"
      '                   Open "C:\dimas password\01.dat" For Output As #1
     '                        Write #1, txtfn.Text, txtln.Text, txtcp.Text
       '                  Close #1
    
    
    End Sub
    
    
    
    
    Private Sub Form_Activate()
    
    'SetFormPosition Form1.hWnd, vbTopMost
    Dim FSO As Object
    
    sfile = "C:\dimas password\01.dat"
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    If FSO.fileexists(sfile) = True Then
    user32.Visible = True
    Form1.Visible = False
    Else
    user32.Visible = False
    Form1.Visible = True
    
    End If
    
    
    Set fs = Nothing
    
    
    End Sub

    (I put the ' infront of the code that I wasn't using)
    oh yea, the form the the textboxes is form 1
    NXSupport - Your one-stop source for computer help

  9. #9
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    this opens and writes to a file if the form1
    comes up...if the file is there it goes to
    user32 form...tested it and it's ok..
    check my code I changed the name of one of your
    text boxes to lower case to match the rest..






    Option Explicit

    Public sfile


    Private Sub Command1_Click()


    'If FSO.FolderExists("c:\dimas password\") Then
    Open sfile For Output As #1
    Write #1, txtfn.Text, txtin.Text, txtcp.Text
    Close #1

    Command1.Enabled = False
    txtfn.Text = ""
    txtin.Text = ""
    txtcp.Text = ""

    ' Else:
    ' MkDir "C:\dimas password\"
    ' Open "C:\dimas password\01.dat" For Output As #1
    ' Write #1, txtfn.Text, txtln.Text, txtcp.Text
    ' Close #1


    End Sub




    Private Sub Form_Activate()

    sfile = "C:\dimas password\01.dat"

    'SetFormPosition Form1.hWnd, vbTopMost
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")

    If FSO.fileexists(sfile) = True Then
    user32.Visible = True
    Form1.Visible = False
    Else
    user32.Visible = False
    Form1.Visible = True

    End If


    Set FSO = 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

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok, 2 things......
    1. its not in, its LN

    2. I still have a problem, the yellow arrow shows to this:

    Code:
    Option Explicit
    
    Public sfile
    
    
    Private Sub Command1_Click()
    
    
    'If FSO.FolderExists("c:\dimas password\") Then
    --------------------> Open sfile For Output As #1
    Write #1, txtfn.Text, txtln.Text, txtcp.Text
    Close #1
    
    Command1.Enabled = False
    txtfn.Text = ""
    txtln.Text = ""
    txtcp.Text = ""
    
    ' Else:
    ' MkDir "C:\dimas password\"
    ' Open "C:\dimas password\01.dat" For Output As #1
    ' Write #1, txtfn.Text, txtln.Text, txtcp.Text
    ' Close #1
    
    
    End Sub
    
    
    
    
    Private Sub Form_Activate()
    
    sfile = "C:\dimas password\01.dat"
    
    'SetFormPosition Form1.hWnd, vbTopMost
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    If FSO.fileexists(sfile) = True Then
    user32.Visible = True
    Form1.Visible = False
    Else
    user32.Visible = False
    Form1.Visible = True
    
    End If
    
    
    Set FSO = Nothing
    
    
    End Sub
    NXSupport - Your one-stop source for computer help

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

    //

    add this to the top of the command1 event
    I know, you shouldn't need to but hey
    give it a shot...It works for me so it must be
    some little thing...

    sfile = "C:\dimas password\01.dat"

    what reason comes with the yellow line

    sorry it takes so long in between, I'm at work and
    flipping back and forth...

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  12. #12
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    Ok..got it...because you have code commented out
    you are trying to open a file for output when the
    directory doesn't exist...
    I deleted the dir on mine and got the same
    problem yellow line on open..make sure the dir
    exists before creating the file to put in the dir.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Re: //

    where do I put the dir?
    NXSupport - Your one-stop source for computer help

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Re: Re: //

    ok, I get it, now lets go back to the beggning, how do I make it check if the directory is already there, and if not, then create it
    NXSupport - Your one-stop source for computer help

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

    Cool << ? >>

    ''complete package...

    Option Explicit

    Public sfile


    Private Sub Command1_Click()

    'SetFormPosition Form1.hWnd, vbTopMost

    Dim fFSO As Object
    Set fFSO = CreateObject("Scripting.FileSystemObject")



    If fFSO.FolderExists("c:\dimas password\") Then
    Open sfile For Output As #1
    Write #1, txtfn.Text, txtln.Text, txtcp.Text
    Close #1

    Command1.Enabled = False
    txtfn.Text = ""
    txtln.Text = ""
    txtcp.Text = ""

    Else:
    MkDir "C:\dimas password\"
    Open "C:\dimas password\01.dat" For Output As #1
    Write #1, txtfn.Text, txtln.Text, txtcp.Text
    Close #1
    End If

    Set fFSO = Nothing

    End Sub




    Private Sub Form_Activate()

    sfile = "C:\dimas password\01.dat"

    'SetFormPosition Form1.hWnd, vbTopMost
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")

    If FSO.fileexists(sfile) = True Then
    user32.Visible = True
    Form1.Visible = False
    Else
    user32.Visible = False
    Form1.Visible = True

    End If


    Set FSO = 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

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Smile Re: << ? >>

    THANKS ALOT, IT WORKED
    NXSupport - Your one-stop source for computer help

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

    oops

    I guess we posted at the same time or whatever.
    that complete one doesn't have the check for
    directory..give me a min or two and I'll send it
    up to you...
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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

    // over and out...

    'add this function and use this new command1 event
    'it cuts down on wated code...

    Public Function DirExists(ByVal sDirName As String) As Boolean

    Dim sDir As String

    On Error Resume Next

    DirExists = False

    sDir = Dir$(sDirName, vbDirectory)
    If (Len(sDir) > 0) And (Err = 0) Then
    DirExists = True
    End If

    End Function


    Private Sub Command1_Click()

    'SetFormPosition Form1.hWnd, vbTopMost

    'if it's not there create it

    If DirExists("C:\diva password\") = False Then
    MkDir ("C:\diva password")
    End If

    Open sfile For Output As #1
    Write #1, txtfn.Text, txtln.Text, txtcp.Text
    Close #1

    Command1.Enabled = False
    txtfn.Text = ""
    txtln.Text = ""
    txtcp.Text = ""



    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

  19. #19

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Re: // over and out...

    WOW, thanks alot, it really worked
    NXSupport - Your one-stop source for computer help

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