Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,458 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,872 people online right now. Registration is fast and FREE... Join Now!




keeping text in a textbox from use to use

 
Reply to this topicStart new topic

keeping text in a textbox from use to use, I've got a log in vb6 that's supposed to save the data you wri

jakerman999
11 Aug, 2008 - 12:45 PM
Post #1

New D.I.C Head
*

Joined: 7 Aug, 2008
Posts: 11



Thanked: 1 times
My Contributions
currently, I have a "log" that will keep all the text you write into it, save it, then load it back into the program the next time it's opened.

currently, my code reads like this:

vb

Dim strName As String
Dim strLog As String

Private Sub Form_Load()
strName = InputBox("enter your name or screen name", "Name?", "The loser with no name")
MsgBox "remember this name, or the log won't carry the same information", vbOKOnly, "Crypt"
lstIn.Refresh
lblIP.Caption = "your IP address is: " & socket1.LocalIP
Open CurDir & "\log\" & strName & ".dat" For Append As #2
On Error GoTo err_handler
If EOF(2) = True Then
Write #2, "anything typed here will be saved and opened at a later date. if you change your name at the beginning of chat, it will be erased."
End If
Close #2
Open "\log\" & strName & ".dat" For Input As #3
Line Input #3, strLog
Close #3
txtStore.Text = strLog
Exit Sub
err_handler:
Select Case Err.Number
Case 53: MsgBox "File Not Found"
Case 55: MsgBox "File Already Open"
Case 71: MsgBox "Disk Not Ready"
Case 76: exit sub
End Select
Resume Next
End Sub

Private Sub txtStore_Change()
Open "\log\" & strName & ".dat" For Output As #4
Write #4, strLog
Close #4
End Sub



this should create a .dat file inside a folder called log(which is already in the same directory as the .exe) containing the contents of log, and displaying them again when the program is next opened.

this should also allow multiple people to have logs, if they have different names.

now the error I'm getting is a simple error 76, file no found(at runtime).and it crashes. when it's compiled into an exe, it loads, but doesn't display the first time message. not only that, but when I change the contents of the textbox, it crashes.

I've looked inside the log folder, and there is a .dat file with my name on it, containing the first time message, so the file is their. now I just need to know what the error is.
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Keeping Text In A Textbox From Use To Use
12 Aug, 2008 - 05:20 AM
Post #2

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,906



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
QUOTE
Open "\log\" & strName & ".dat" For Input As #3  

Your relative addressing format is incorrect.

You need to specify that the path is relative to the current directory. Hence, you must prefix your path with a period '.' like this:
vb
Open ".\log\" & strName & ".dat" For Input As #3


It should work now.
smile.gif
User is offlineProfile CardPM
+Quote Post

jakerman999
RE: Keeping Text In A Textbox From Use To Use
12 Aug, 2008 - 09:51 AM
Post #3

New D.I.C Head
*

Joined: 7 Aug, 2008
Posts: 11



Thanked: 1 times
My Contributions
great, that works for the most part, but now I get error 55: file already open. any reason for this?

edit:never mind,I had the wrong file number. it works exactly like I wanted to. thanks for your help.

This post has been edited by jakerman999: 12 Aug, 2008 - 10:10 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:44PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month