473,467 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB6 write to .txt file

3 New Member
This is for a school project. I made a log in system that sorta works.. there is just one problem.

The problem is when registering a new user.
What I'm doing is, I make a new .txt file for each user with on the first line the user name and the second line the password.
The problem is, when the file is created and the data is stored it is stored with the annoying little @#$&*: "..."

So then when it reads from the text file it reads the ".."
Eg.

When user enters his password as: ABCD
The program compares it to the file which has: "ABCD"
therefore the user is denied access.

My question: How do I get rid of the "..."
Thanks in advance.

I think the problem is really in the last 5 lines.

RegUNam, RegPass are dimmed as String
Expand|Select|Wrap|Line Numbers
  1. Register_Name:
  2. RegUNam = InputBox("Enter desired username", "Username")
  3. If RegUNam = "" Then
  4. Response = MsgBox("Do you wish to try again?", vbYesNo, "Username")
  5. If Response = vbYes Then GoTo Register_Name
  6. If Response = vbNo Then Exit Sub
  7. End If
  8. RegPass = InputBox("Enter password", "Password")
  9. If RegPass = "" Then
  10. Response = MsgBox("Do you wish to try again?", vbYesNo, "Username")
  11. If Response = vbYes Then GoTo Register_Name
  12. If Response = vbNo Then Exit Sub
  13. End If
  14.  
  15. Open "E:\Multimedia\Documents\Marco\SDD\Assignment\Users\" & MyName & ".txt" For Output As #2
  16. Write #2, RegUNam
  17. Write #2, RegPass
  18.         Close #2
  19.         MsgBox "User created."
  20.     Exit Sub
Also, as you can see it opens from "E:\Multimedia\Documents\Marco\SDD\Assignment\ "
Is it possible to replace that to something that finds the directory all the files are stored in? Because the file is saved on a USB stick and therefore the drive changes.. and also it is being installed on different computers.
*The project is saved in this folder and the user in this folder\Users\

THANK YOU FOR HAVING A LOOK!!
Jul 31 '08 #1
4 3349
debasisdas
8,127 Recognized Expert Expert
Please find related discussions here ,here and here .
Jul 31 '08 #2
DutchMarco
3 New Member
Thank you for the reply, but those all read from the file, where I need to write to the file.
I'm only new at VB and I really need to use this format.

can you help me with simply removing the " " that has been added around RegUNam and RegPass? I appreciate your help.

Expand|Select|Wrap|Line Numbers
  1. Open "Users\" & MyName & ".txt" For Output As #2 
  2. Write #2, RegUNam 
  3. Write #2, RegPass 
  4.         Close #2 
  5.         MsgBox "User created." 
  6.     Exit Sub
Aug 1 '08 #3
DutchMarco
3 New Member
No worries.. I found a different way to do it.

instead of changing the writing, I changed the reading.
It used to be Line Input #1, Saved_Name
Now it's just Input #1, Saved_Name

That ignores the " " in the .txt file
Aug 1 '08 #4
debasisdas
8,127 Recognized Expert Expert
That is really great.

Thats how you keep learning new things by experimenting.
Aug 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ellixis | last post by:
Hello, How can I use fwrite() and fseek() in order to write data in the middle (or anywhere else) of a file without overwriting existing data ? People told me that I should load the file into...
5
by: Just Me | last post by:
Using streams how do I write and then read a set of variables? For example, suppose I want to write into a text file: string1,string2,string3 Then read them later. Suppose I want to write...
6
by: sambuela | last post by:
How can I write message to the file located in the wwwroot directory? It seems that IIS protect these files. Let make me cannot do the I/O writing sucessfully. I try to open file's write...
2
by: ykgoh | last post by:
Hi. I've a problem of being able to create and remove a directory but unable to write a file inside the created directory for some strange reason. I suspect that this problem could be vaguely...
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
1
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example,...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
6
by: globalrev | last post by:
i ahve a program that takes certain textsnippets out of one file and inserts them into another. problem is it jsut overwrites the first riow every time. i want to insert every new piece of...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
Oralloy
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.