-----------------------------------------------------------------------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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
System.IO.File.WriteAllText("Password.txt", "C:\Documents and Settings\Admin\My Documents\Password.txt")
End Sub
Private Sub AddNewLoginToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddNewLoginToolStripMenuItem.Click
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,textbox2,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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fs As System.IO.FileStream = New System.IO.FileStream("C:\Myfile.txt", IO.FileMode.OpenOrCreate)
Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(fs)
'Note vbcrlf just means I am adding a line feed to start the next line
sw.Write(Me.textbox1.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Write(Me.textbox2.Text & vbCrLf) 'Text box 1 has the Login Name
sw.Write(Me.textbox3.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.StreamReade 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.StreamReader = New system.io.StreamReader("C:\myfile.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?
3 1786
Lets break this down a little... 1 at a time.
searching a textbox...
I assume you mean look into the database and see if the username entered existes in the database... right?
So...
1. You connect to a database...
2. run your query (check if Username.text is in the database...)
3. if it is check the correspoding password... if correct do something
is this along the lines of what you require?
Thanks James
Question moved to .NET Forum.
I don't think your file IO is quite right.
the format is
System.Io.File.WriteAllText(filename, text-to-write);
You should have a common format for writing your data. Possibly CSV style:
<website>, <username>, <password>
<website>, <username>, <password>
<website>, <username>, <password>
Which can be read and scanned easily.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Zorba.GR |
last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64
bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite
Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
|
by: Microsoft |
last post by:
Hi,
I have Visual Basic .net 2003 (Standard Edition) & SQL Server 2000 Developer Edition. When trying to create a connection in the server explorer from the .net IDE I get a number of problems;...
|
by: amber |
last post by:
Hello,
I use Visual Studio .NET 2003 Professional version at work.
I'd like to buy .NET for my home PC.
All I use is VB.NET and I'd like to use ASP.NET eventually.
What kind of functionality etc...
|
by: Notgiven |
last post by:
I have visual studio 2003 but am just starting to learn in earnest and
wonder if I can use vs. 2003 or do I need to upgrade?
If I need to upgrade, is there an inexpesive way to do this? (looks...
|
by: Hunk Gym |
last post by:
VB.Net of Visual Studio.Net 2003 VS Visual Basic 2005 Express Edition
Good Day!
Would be appreciate if there is solution for the following problem:
- In VB.Net of Visual Studio.Net 2003,...
|
by: Gabriel |
last post by:
Hello,
I installed SQL server 2005 SP1 on a Windows XP SP2
From Visual Studio, I'm trygin to create a connection to a database, but I
receive this error but I'm creating the connection (I...
|
by: Preben Zacho |
last post by:
Hi there
The scenario I got is this: I have created a Windows application in VS and I
want to deploy it to another machine running Windows Vista. Since I have no
control over this other machine,...
|
by: Scott M. |
last post by:
I've seen many posts and ready articles discussing how changing the
membership & roles "provider" in VS .NET is easy, but have yet to see
instructions on how to do it.
If I already have SQL...
|
by: BobLewiston |
last post by:
I installed SQL Server 2008 Express, basic edition (SQLEXPR32_x86_ENU_Bootstrapper.exe, version 9.0.30729.1) without any problem.
Then I attempted to install AdventureWorks Sample Databases for...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |