Solved

VB6 pw and read data from TXT file...

Posted on 2004-09-29
8
318 Views
Last Modified: 2010-05-02
Hello, I need help with VB6
I am making a project for school
and its little program that will ask for log-in name & password and then its gonna take you to a different window
well my question is how can i store file in txt file and lets say for example i click on name ex "Stan" it will give all the information about that person that i stored in txt file..ex:   Name:                Last Name:               Phone:  and ect. and also be able to view all the names if more thatn one...


thank you....i dunno about the points i havent use EE for a long time... so if u think im not giving u enought points for this question please say so..

thanks
0
Comment
Question by:Stan12
8 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 12186368
try use your store media in Access, or Excel? If still prefer text file, i suggest you use the INI file format, so that you can read the file detail easily by using API. So which one you prefer?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12186490
Another option is to create a UDT (User Defined Type) to handle your data and store the records in a random access file.

Private Type StudentRecord
    strLastName As String * 25
    strFirstName As String * 25
    strPhoneNumber As String * 15
    ' etc., etc., etc....
End Type

If you open a file in random mode, then you can read/write entire records either in a sequential manner, or by specifying a record number.  The drawback to random access files is that your data sizes must be decided upon beforehand.  You have to give each field the proper numeric type or allocate enough string space to handle the largest value you think you will encounter.

I would only use random access files for small projects however, since as file gets larger, your access time will begin to suffer.  Also, it is a pain to handle relational data since you have to use two files making the access time even longer.

Here is a PAQ with a very basic example in it:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20884901.html

Regards,

Idle_Mind
0
 

Author Comment

by:Stan12
ID: 12186629
Ok for example lets say i use Exel to store all the data which will be actually even better. can u provide me with script please that will allow me to open it in VB project. like ok im sorry i messed up here a little bit.... lets say i have 2 exel files one that contans all Names/Last names only ok? and i have another exel doc that contans that persons information in for example 4 columns
and what im trying to hah more like trying to learn is how can i load excel file that contans the names in to ListBox and then if for example i pick one name from list box and press button "Comman1" it will display that persons information in PictureBox or Frame.

thanks a lot.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 12186845
How big is your data? And for better maintenance in future, will it possible you combine your 2 excel files, and eventually i will suggest you to use Access database, possible ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Accepted Solution

by:
anv earned 220 total points
ID: 12186894
check the following link

http://support.microsoft.com/default.aspx?scid=kb;EN-US;257819

using connections as per the provided in the above link..

fetch alll names from excel file1 using simple sql query

rs.open "Select distinct [Name] from Sheet1", cn  'where Sheet1 is the name of the worksheet from where u want to fetch teh data. cn is active connection.and rs is the recordset

store the data into a combo box..

if not rs.eof
  while not rs.eof
      combo1.additem rs![Name]
      rs.movenext
  wend
end if

now depending on the selection made in the combo box fill the details as
open the excel file2

rs2.open "select * from Sheet2 where [Name]  = '" & combo1.List(cmbo1.Listindex) & ''", cn2  

now fill all the controls withthe data using rs2..

like..
txtAge.text =rs2!Age
txtPhone.Text = rs2!Phone..

and so on..

include the above on search code on the click of a command button..
0
 
LVL 3

Expert Comment

by:thunder_moose
ID: 12187647
I'd actually recommend you go with a database to store your stuff in. The thing with text files and excel files is that anybody can easily open them and see your data. You can password protect an excel file of course, but excel isn't really meant to be used as a database.

I know it's only for a project, but your teacher is probably going to tell you the same thing, and you'll probably get better marks if you do it properly.

Personally I'd just dump it all in a SQL database and look up the user based on his username.

That's just my two cents though.
TM
0
 

Author Comment

by:Stan12
ID: 12191073
well yeah SQL database and all this stuff sound nice and professional but the problem is im just a begginer newbie in another words, this is my 3rd project. i used VB6 before like 2-3 years ago but i really dont remeber anything in it so i dont know can someone provide me an examples or simlest SCRIPTS because that way i will understand better. Its alot easyer for me to look at ready code and then understanding it. Thanks

sorry for all the trouble.
0
 

Author Comment

by:Stan12
ID: 12197125
So can somebody help me out here please?


thanks :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Opening Remote & Local Data Connection 2 51
passing parameter in sql procedure 9 56
Access Object Property from VBA Module in Excel 2010 2 27
Problem to With line 4 42
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now