|
-
May 19th, 2005, 03:39 AM
#1
Thread Starter
New Member
bad filename error :( (vb6)
Code:
Dim tmp As Variant
Dim Users As Integer
Dim strLineValue As String
Dim strValueToFind As String
Sub CreateFileAndWrite()
Users = FreeFile
'Open the document to write to. Look in the documentation
'at the Open statement for more information and different modes.
Open "\\ict-server\stud_redir\davidmica\dtop\personal PR\Users.txt" For Output As Users
'Use the print or Write statement to add data to the file.
'Again, the documentation will give you more info.
Print #Users, tmp
'Close the file.
Close #Users
End Sub
Sub WriteInFile()
Users = FreeFile
'Set the string you want to find in the file.
strValueToFind = tmp
Open "\\ict-server\stud_redir\davidmica\dtop\personal PR\Users.txt" For Input As Users
'Read each line until either the string has been
'found or you have reached the end of the file.
Do Until EOF(Users)
Line Input #Users, strLineValue
If InStr(strLineValue, strValueToFind) > 0 Then
MsgBox "User you Selected Already Exists, Sry"
'Close the file and exit this loop
Close #Users
Exit Do
Else
End If
Loop
Close #Users
End Sub
Private Sub cmdCheckUser_Click()
Set Myfso = CreateObject("Scripting.FileSystemObject")
tmp = txtUser.Text
If (tmp = "") Then
MsgBox "Please Enter A Username Before You Click Check, Thanks", , "No Username Found!"
Else
MsgBox "Please Wait... while checking your username availability", , "Please Wait"
If (Myfso.FileExists("\\ict-server\stud_redir\davidmica\dtop\personal PR\Users.txt")) Then
MsgBox "hello"
Call WriteInFile
Else
Call CreateFileAndWrite
End If
End If
End Sub
it is givving me bad filename error
-
May 19th, 2005, 03:42 AM
#2
Hyperactive Member
Re: bad filename error :( (vb6)
this is not a valid path
"\\ict-server\stud_redir\davidmica\dtop\personal PR\Users.txt"
-
May 19th, 2005, 04:05 AM
#3
Thread Starter
New Member
Re: bad filename error :( (vb6)
 Originally Posted by user name
this is not a valid path
"\\ict-server\stud_redir\davidmica\dtop\personal PR\Users.txt"
huh? it has been created with that path!
-
May 19th, 2005, 04:19 AM
#4
Re: bad filename error :( (vb6)
It's a long code. Which line gives error?
-
May 19th, 2005, 04:32 AM
#5
Thread Starter
New Member
Re: bad filename error :( (vb6)
 Originally Posted by Pradeep1210
It's a long code. Which line gives error?
it is trying to check if the users already exisits or not in the file.txt if it is not in the file then it will be written in the file.txt the new user
-
May 19th, 2005, 04:38 AM
#6
Re: bad filename error :( (vb6)
Which line is the error on? Is it a permission error?
-
May 19th, 2005, 04:40 AM
#7
Re: bad filename error :( (vb6)
this is not your original problem, but if you want to add a new user to the file, better to open file for append.
if you only want to keep the new user then open for output is fine.
maybe you should destroy your FSO object before trying to open the file
pete
-
May 19th, 2005, 07:21 AM
#8
Thread Starter
New Member
Re: bad filename error :( (vb6)
ok, let me try it out!
Thanks
-
May 20th, 2005, 09:23 AM
#9
Thread Starter
New Member
Re: bad filename error :( (vb6)
Code:
Sub CheckUserAvailability()
intFileNumber = FreeFile
'Set the string you want to find in the file.
strValueToFind = tmp
Open "\\ict-server\stud_redir\davidmica\dtop\personal PR\Users.txt" For Random Access Read As intFileNumber
'Read each line until either the string has been
'found or you have reached the end of the file.
Do Until EOF(intFileNumber)
Line Input #intFileNumber, strValueToFind
If InStr(intFileNumber, strValueToFind) > 0 Then
MsgBox "Found the string"
'Close the file and exit this loop
Close #intFileNumber
Exit Do
End If
Loop
Close #intFileNumber
End Sub
it's not working well.. i am trying to see if a user already exists in a file.txt and it's not working!
-
May 20th, 2005, 09:33 AM
#10
Re: bad filename error :( (vb6)
No, I guess it isn't working.
'Set the string you want to find in the file.
strValueToFind = tmp
'strValueToFind will be replaced with a line from the file, so it looses it's original value.
Line Input #intFileNumber, strValueToFind
' this line doesn't make any sense, you check if the line you just read from the file can be found in the filenumber (probably just 1)
If InStr(intFileNumber, strValueToFind) > 0 Then
-
May 20th, 2005, 09:33 AM
#11
Re: bad filename error :( (vb6)
random won't work the way you are doing it open for input
Line Input #intFileNumber, strFromFile
If InStr(strFromFile, strValueToFind) > 0 Then
try that
pete
-
May 21st, 2005, 01:39 AM
#12
Thread Starter
New Member
Re: bad filename error :( (vb6)
thabks.. i will check them out and tks everyone who is helping me
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
|