-
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..
-
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.
-
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..
-
Hi!
I just answered your question in This thread.
Enjoy!
-
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. :)