Results 1 to 5 of 5

Thread: help, need to make file name checker

  1. #1

    Thread Starter
    Junior Member russianvbabe's Avatar
    Join Date
    Sep 2000
    Posts
    20
    hey, I have to make a file name checker, that works like this:
    when clicking a button on my form, it will check the writen text inside a text box. and it has to see if that text is a proper file name ie: no criptic charactors like $,#<& have no spaces, as well it should included the 8.3 naming conventions.
    -- if its not right and error should be returned to the user, and if its good, then the user should know that too
    please help, I dont even know where to start..

  2. #2
    Guest

    Smile Obviously...

    Hmmm...

    Code:
    Private Sub ButtonName_Click()
        Dim Errorfd as Boolean
        If InStr( ,Text1,"&") <> 0 Or vbNull then ErrorFd = True
        'A lot more of these, replacine "&" with a symbol.
    
    
        If errorfd = True then 
            MsgBox "Error: A filename cannot contain: " & "symbols" _
            , vbExclamation, "Error in Filename" 
        Else 
            MsgBox "Everything in the Name is Fine.", vbInformation, "No Errors!"
        End If
    End Sub
    Hope it helps.

  3. #3

    Thread Starter
    Junior Member russianvbabe's Avatar
    Join Date
    Sep 2000
    Posts
    20

    Lightbulb Thank you, but?

    ok I think this might be helping, but I need a walk threw of the code.. just so I know how to understand it.. If you or someone doesn't mind...
    sorry I'm a bit dumb when it come to this program.
    I also thing there may be more to it that I need..

  4. #4
    Guest
    Hi!

    I just answered your question in This thread.

    Enjoy!

  5. #5
    Guest

    Talking I'll explain happily.


    Code:
    Private Sub ButtonName_Click()
    Obviously, this is an EVENT sub which is fired whenever ButtonName is Clicked on.

    Code:
        Dim Errorfd as Boolean
    This part DIMs the varibles so that it can be used ONLY IN THIS SUB.

    Code:
        If InStr( ,Text1,"&") <> 0 and InStr( ,Text1,"&") <> vbNull then ErrorFd = True
        'A lot more of these, replacine "&" with a symbol.
    It checks for these symbols and, if it finds them, makes ErrorFD equal True.
    InStr() checks for the String and checks if the characters are in the string.

    Code:
        If errorfd = True then 
            MsgBox "Error: A filename cannot contain: " & "symbols" _
            , vbExclamation, "Error in Filename" 
        Else 
            MsgBox "Everything in the Name is Fine.", vbInformation, "No Errors!"
        End If
    End Sub
    Finally, Action. It checks if the ErrorFD is true (or if there's that error) and makes an error if it is. Also makes a confirmation if it's not.

    Didnot mind explaining.

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