473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

VB6 write to .txt file

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 3335
debasisdas
8,127 Expert 4TB
Please find related discussions here ,here and here .
Jul 31 '08 #2
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
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 Expert 4TB
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.