Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 3rd, 2007, 12:38 AM
Registered User
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading from a Text file for Login and Password..

ok people, my first post, im relativly new (but still expirienced) to vb express and currently making a login section for my project...

i have a save, load and delete button where the user would be able to choose from.. i have the save section working where the user would enter thier username and password and it would save to a text box located in c:\ .. that all works.. with my load section i ask the user to input thier username and password, and i read my text file which is in c:\ and tell it to steamread etc.etc.. eventually the code gets the text inside the text file and puts it into a multiline textbox on the form.. at this point everything works fine.. here is my problem:

i need to search this multiline textbox to find the username which the user inputs eg:

username = textbox1.text

i want to the code to search the whole multiline textbox to find this STRING username (textbox1.text) and if the multiline textbox DOES have this specific text then it would display a msgbox such as "Enter the game"

here is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim file As System.IO.StreamReader

If System.IO.File.Exists("C:\pokemonlogin.txt") = True Then

If txtlogin.Text <> "" And txtpassword.Text <> "" Then

file = System.IO.File.OpenText("c:\pokemonlogin.txt")
'WHERE TEXTBOX3 is the multiline text box
TextBox3.Text = file.ReadToEnd

'(problem starts from from here)---->
If textbox3.something which represents string = the string in txtlogin.text then
MsgBox("well done")


' MsgBox("Please enter a REAL username or create one!!!")

End If

End If


MsgBox("Pokemon Blue Gem Arcade does not detect ANY previous users, please create one")

End I

i dont want the whole text of one textbox to equal another whole text of another textbox.. i want it to search and find only a specific text (which is a variable, which the user inputs)

EG: user types in textbox1 "johnny"
textbox2 reads a file from c:\ then displays it in textbox2
a command/function which represents "a find string( or sumthing like that" will use the two textboxes to compare each other..

Please help me out people... if im not clear enough then please ask.. all help and code would be much appriciated!!!

Old July 3rd, 2007, 07:11 AM
Authorized User
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196

If I have interpreted your problem correctly then this should be simple. Otherwise you will need to clarify a little more.

1.) The input for TextBox1 is "Johnny"
2.) You read in your text file into Textbox2.
3.) You compare by:

If TextBox2.Text.Contains(TextBox1.Text) Then
    '* Your Welcome Code Here

Best Regards,
Earl Francis
Old July 4th, 2007, 01:03 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

I'm a little confused by the original post. The term "textbox" was used in a few places that I would have expected the term "text file" so I'm not clear which was intended.

If you have the option to decide how you are going to store information in a file, why not use a better file format that is easier to use such as XML? You could store the login information as XML so there's no question of what text from the file constitutes the data.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Text file from Resource folder balesh.mind ASP.NET 3.5 Basics 1 November 14th, 2008 06:54 AM
Reading a Text File gmoney060 Classic ASP Basics 2 October 30th, 2004 01:43 AM
reading text file Regornil JSP Basics 2 October 27th, 2004 02:02 AM
Reading ASCII data from text file. LordBeholder VB How-To 2 June 25th, 2004 05:50 PM
Reading from a text file and writing to a Binary 1 scott01 C++ Programming 0 July 28th, 2003 03:59 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.