|
-
May 13th, 2003, 07:18 AM
#1
Thread Starter
Lively Member
file name verification problems
Hi,
I hope someone can help me Please!
Here's what i want to do - from my VB appln when a user selects a file from the file browser in the vb appln, it takes the filename which should be in the format : -
(4 digits-2digits-1or2digits-alphabet) e.g. 1111-20-1-a.dwg
It then checks whether the filename is in the correct format
If not it does this(...) else
it takes the filename and puts it in a textbox BUT WITHOUT THE file extension (e.g. 1111-20-1-a gets entered into text box)
areas in which I am having a problem is basically
1) performing the check on the filename and
2) which is related to the first one is getting the filename into a textbox without the file extension.
Any help would be much appreciated
Regards
Eb
-
May 13th, 2003, 07:23 AM
#2
2
VB Code:
Temp = Mid(filename, InStrRev(filename, "\") + 1)
Temp = Mid(Temp, 1, Len(Temp) - 4)
Has someone helped you? Then you can Rate their helpful post. 
-
May 13th, 2003, 07:24 AM
#3
-
May 13th, 2003, 07:30 AM
#4
Here is a simple example. You'll still need to check i if the "-" are in the right positions.
VB Code:
Option Explicit
Dim Filename As String
Dim Temp As String
Dim i As Integer
Private Sub Form_Load()
Filename = InputBox("Enter filename", "Enter filename")
Temp = Mid(Filename, InStrRev(Filename, "\") + 1)
Temp = Mid(Temp, 1, Len(Temp) - 4)
For i = 1 To Len(Temp)
If IsNumeric(Mid(Temp, i, 1)) = False And Asc(Mid(Temp, i, 1)) <> 45 Then
MsgBox "Invalid filename"
Exit Sub
End If
Next
End Sub
Has someone helped you? Then you can Rate their helpful post. 
-
May 13th, 2003, 07:36 AM
#5
Thread Starter
Lively Member
with your example : -
Temp = Mid(Filename, InStrRev(Filename, "\") + 1)
Temp = Mid(Temp, 1, Len(Temp) - 4)
will that only chck the first 4 values of the filename
Then if that succeeds I have to check "-" then the next 2 digits
and so on ????
-
May 13th, 2003, 07:39 AM
#6
-
May 14th, 2003, 03:36 AM
#7
Thread Starter
Lively Member
Ok that works BUT how do i check for AlphaNumeric values
The way I have done it is : -
If (Mid(Temp, 6, 2)) Like "[A-Z]" = False And IsNumeric(Mid(Temp, 6, 2)) = False Then
MsgBox "Invalid filename - error in SFB number"
Exit Sub
End If
Is there a function that checks whether the value is a integer or a letter???
PS: I am using VB6 SP5 because I think VB.NET has function called IsAlphaNumeric but VB6 doesn't
-
May 14th, 2003, 07:59 AM
#8
-
May 14th, 2003, 08:02 AM
#9
Thread Starter
Lively Member
Thank you very much for your help
-I have sorted it out now!!!!
-
May 14th, 2003, 08:28 AM
#10
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|