Computer Science Canada

Strange error...

Author:  BioHazardousWaste [ Sat Mar 13, 2004 2:49 pm ]
Post subject:  Strange error...

Hey Tony, Simpson... ne1 else who knows VB

Some dumbass at my skool made a .txt file on our student common drive called chatprogram.txt.. well me and a couple friends went in there and reamed him out, about it being a text file and not a program (during 1st period programming, in Turing) Neways... he's like o BS let's see UR proggy then. So, I figure WTH? I'll make one.

I ran into the queerest problem with the time...

{EXAMPLE}
I {Steve0} join the "server"

code:

ChatTime = #4:35:17 PM#
ChatTime = Time

Open "s:\chat.dat" For Append As #1
Print #1, ChatTime & " - " & "{" & Form2.LoginName & " IS JOINING SERVER}"

Close #1


Which works fine... when u open the datafile it says
Quote:
4:46:35 PM - {Steve0 IS JOINING SERVER}


like it should.. BUT when I read it back in

code:

MaxChat = 0

Open "s:\chat.dat" For Input As #4
   
    For i = 1 To 750
        If EOF(4) = True Then
            Exit For
        End If
       
        Input #4, ChatInput
        ChatData(i) = ChatInput
        MaxChat = MaxChat + 1
    Next i
   
    If OldChat = ChatData(MaxChat) Then
    Else
        OldChat = ChatData(MaxChat)
       
        txtChat.Text = ""
       
        For i = 1 To MaxChat
            txtChat.Text = txtChat.Text & vbCrLf & ChatData(i)
        Next i
       
       
    End If


my "chat" box says

Quote:

4
PM - {Steve0 IS JOINING SERVER}


any ideas why it doesn't say exactly whats in the file, and how to make it?

it's just the time thats messed up

Author:  Brightguy [ Mon Mar 15, 2004 11:16 pm ]
Post subject:  Re: Strange error...

I think the problem must be that the file output is not properly delimited. To correct this, use the Write # statement instead of the Print # statement.

Alternatively, I think you could use the Line Input # statement which reads all text until a new line (vbCrLf character).


: