|
-
Oct 21st, 2007, 07:00 PM
#1
Thread Starter
New Member
Deleting certain parts of a text file
I am creating a childrens program where the user has an opportunity to change their password or delete an account. The information is inside a text file and i don't know how to delete only the password etc... At the moment my code is:
vb Code:
Public Function ChangePassword_Click(ByVal password As String, ByVal start As Integer, ByVal length As Integer, ByVal studentpass2 As String) As String
studentpass1 = InputBox("Please enter your previous password.")
studentpass2 = InputBox("Please enter your new password.")
If start + length >= Len(password) Then
DeleteSubString = Left(password, start - 1)
Else
DeleteSubString = Left(password, start) & Mid(password, start + length + 1)
End If
InsertSubString = Left(password, start - 1) & studentpass2 & Mid(password, start)
MsgBox ("You have successfully changed your password"), vbExclamation
End Function
I have also tried this:
Private Sub cmdchangepassword( ) Click
Function (byVal username as String, ByVal password as String, ByVal studentpass1 as String, ByVal studentpass2 as String) as String
Replace (password, studentpass1, studentpass2
End Function
Nothing is working!!!
Last edited by Hack; Oct 22nd, 2007 at 06:37 AM.
Reason: Added Highlight Tags
-
Oct 21st, 2007, 07:46 PM
#2
Member
Re: Deleting certain parts of a text file
whats the format of the text file?
-
Oct 22nd, 2007, 03:56 AM
#3
Re: Deleting certain parts of a text file
Read the text file into memory.
Write it to a new file using the new password.
Erase the old file.
Rename the new file as the old one.
The effect will be as if you'd actually changed the line where the password resided.
Remember to make a backup of the original file until you're quite sure your code is working.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Oct 22nd, 2007, 05:32 AM
#4
Re: Deleting certain parts of a text file
you will either have to do it like he just said, or you will have to create your textfile with fixed field lengths and edit it in binary or random mode.
-
Oct 24th, 2007, 04:21 PM
#5
Thread Starter
New Member
Re: Deleting certain parts of a text file
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
|