-----------------------------------------------------------------------QUESTION
hi i am really stuck with this and its only a small problem.
i want to be able to type .........
dsfsjfjsjjfs in User Box
fjdjskfjds in password box
www.thescripts. com in website box
then i want to have a button which says "save" which then saves the 3 above pieces of text into a notepad file.
So like I said I want to be able to type a login, password and website in the 3 textboxes then click a button which saves it into my .txt file.
Just make any required adjustments to do this. I am really confused with this so any help would be appreciated.
this has really confused me so please help
Code: ( vbnet )
1.
Public Class Form1
Dim Login As String
Dim Password As String
Dim Website As String
Private Sub Label1_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label1.Click
End Sub
Private Sub TextBox1_TextCh anged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles TextBox1.TextCh anged
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
System.IO.File. WriteAllText("P assword.txt", "C:\Documen ts and Settings\Admin\ My Documents\Passw ord.txt")
End Sub
Private Sub AddNewLoginTool StripMenuItem_C lick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles AddNewLoginTool StripMenuItem.C lick
End Sub
End Class
also after i want to have a search box where you type in like www.thescripts into 1 box which then finds you the user name and password for that website.wot would i do here?
if you dont have much time just help me figure out where iam going wrong on the first part then leave the search problem untill you have some time
regards
george
--------------------------------------------------------------------------ANSWER
Step 1. Create a new windows form
Step 2. Add 3 Text box's from the Toolbox to the form (I am assumign the names are textbox1,textbo x2,textbox3)
Step 3. Add a save button
Step 4. Double Click the save button to bring you into the code
use this code
Code:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim fs As System.IO.FileS tream = New System.IO.FileS tream("C:\Myfil e.txt", IO.FileMode.Ope nOrCreate)
Dim sw As System.IO.Strea mWriter = New System.IO.Strea mWriter(fs)
'Note vbcrlf just means I am adding a line feed to start the next line
sw.Write(Me.tex tbox1.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Write(Me.tex tbox2.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Write(Me.tex tbox3.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Close()
fs.Close()
End SubThis will add the info every time you click save to the file. If you want to read the file you do the same thing, except use the System.IO.Strea mReade object. You will need to look up it's funcitonality.
Here is some code that shows you how to read each individual line in the file.
Code:
Dim sr As system.io.Strea mReader = New system.io.Strea mReader("C:\myf ile.txt")
Try
Do While True
Dim s As String = sr.ReadLine()
If s Is Nothing Then
Exit Do
Else
' Change this to do whatever you want with the line.
msgbox(s)
End If
Loop
Finally
If Not sr Is Nothing Then
sr.Close()
End If
End TryNow with that being said, it is possible to code this and make it work fairly easy. However the correct approach would be to store this as a delimited file, or a xml file.
Look up this online, but hopfully this will give you a start
-------------------------------------------------------------------------------------NEEDED
ok firstly i posted about my idea online....
someone posted back sayin the answer 2 my problem however,
1.
"Here is some code that shows you how to read each individual line in the file."
i dont understand what he means after this sentence in the answer part.
2.
when the user clicks save and the data is saved into the text file i want you 2 be able to save multiply logins not just 1.
3.
what code would i use 2 search a login using a textbox?
hi i am really stuck with this and its only a small problem.
i want to be able to type .........
dsfsjfjsjjfs in User Box
fjdjskfjds in password box
www.thescripts. com in website box
then i want to have a button which says "save" which then saves the 3 above pieces of text into a notepad file.
So like I said I want to be able to type a login, password and website in the 3 textboxes then click a button which saves it into my .txt file.
Just make any required adjustments to do this. I am really confused with this so any help would be appreciated.
this has really confused me so please help
Code: ( vbnet )
1.
Public Class Form1
Dim Login As String
Dim Password As String
Dim Website As String
Private Sub Label1_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label1.Click
End Sub
Private Sub TextBox1_TextCh anged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles TextBox1.TextCh anged
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
System.IO.File. WriteAllText("P assword.txt", "C:\Documen ts and Settings\Admin\ My Documents\Passw ord.txt")
End Sub
Private Sub AddNewLoginTool StripMenuItem_C lick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles AddNewLoginTool StripMenuItem.C lick
End Sub
End Class
also after i want to have a search box where you type in like www.thescripts into 1 box which then finds you the user name and password for that website.wot would i do here?
if you dont have much time just help me figure out where iam going wrong on the first part then leave the search problem untill you have some time
regards
george
--------------------------------------------------------------------------ANSWER
Step 1. Create a new windows form
Step 2. Add 3 Text box's from the Toolbox to the form (I am assumign the names are textbox1,textbo x2,textbox3)
Step 3. Add a save button
Step 4. Double Click the save button to bring you into the code
use this code
Code:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim fs As System.IO.FileS tream = New System.IO.FileS tream("C:\Myfil e.txt", IO.FileMode.Ope nOrCreate)
Dim sw As System.IO.Strea mWriter = New System.IO.Strea mWriter(fs)
'Note vbcrlf just means I am adding a line feed to start the next line
sw.Write(Me.tex tbox1.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Write(Me.tex tbox2.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Write(Me.tex tbox3.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Close()
fs.Close()
End SubThis will add the info every time you click save to the file. If you want to read the file you do the same thing, except use the System.IO.Strea mReade object. You will need to look up it's funcitonality.
Here is some code that shows you how to read each individual line in the file.
Code:
Dim sr As system.io.Strea mReader = New system.io.Strea mReader("C:\myf ile.txt")
Try
Do While True
Dim s As String = sr.ReadLine()
If s Is Nothing Then
Exit Do
Else
' Change this to do whatever you want with the line.
msgbox(s)
End If
Loop
Finally
If Not sr Is Nothing Then
sr.Close()
End If
End TryNow with that being said, it is possible to code this and make it work fairly easy. However the correct approach would be to store this as a delimited file, or a xml file.
Look up this online, but hopfully this will give you a start
-------------------------------------------------------------------------------------NEEDED
ok firstly i posted about my idea online....
someone posted back sayin the answer 2 my problem however,
1.
"Here is some code that shows you how to read each individual line in the file."
i dont understand what he means after this sentence in the answer part.
2.
when the user clicks save and the data is saved into the text file i want you 2 be able to save multiply logins not just 1.
3.
what code would i use 2 search a login using a textbox?
Comment