Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:41:43+00:00 2026-06-07T07:41:43+00:00

Okay so for an internship project i’m making a Journal with streamwriters and streamreaders.

  • 0

Okay so for an internship project i’m making a Journal with streamwriters and streamreaders.

I have to to where you can create an account with a name, Username, and Password. I also have it to where it creates a txt file in that persons name when you create the account. Now, they login and it brings them to the journal page. The Journal Page for the most part has a Date for your journal Entry, the title of the journal and the journal entry text itself.

The problem that I am having is that when you click the button to create/edit a journal entry, it goes through a sub routine that checks if that journal exists (Meaning that there is already one for that date) or not. If it doesn’t exist, then it should create a new one at the bottom of the text file. If it does exist then it should edit the lines in which that journal are stationed in the text file.

Code:

Private Sub CreateBtn_Click(sender As System.Object, e As System.EventArgs) Handles CreateBtn.Click

    Errors = ""

    Dim TempCounter As Integer = 0

    If TitleTxt.Text = "" Then

        Errors = "You must enter a title." & vbCrLf

    End If


    If JournalTextRtxt.Text = "" Then

        Errors &= "You must enter an entry for the journal."

    End If

    If Errors <> "" Then

        MessageBox.Show("There's an error in creating/editing your journal." & vbCrLf & "Error(s):" & vbCrLf & Errors, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

    Else

        JournalDate = DateTimePicker1.Value
        JournalTitle = TitleTxt.Text
        JournalText = JournalTextRtxt.Text

        arrJournalEntries(TempCounter).TheDate = JournalDate
        arrJournalEntries(TempCounter).Title = JournalTitle
        arrJournalEntries(TempCounter).JournalEntry = JournalText



        CheckAndWrite()

    End If

End Sub

Private Sub CheckAndWrite()

    Dim Reader As New StreamReader(MyName & ".txt", False)
    Dim Sline As String = Reader.ReadLine

    Counter = 0

    Do Until (Sline Is Nothing) 'Perform the code until the line in the text file is blank

        If Not Sline Is Nothing Then 'If the line in the text file is NOT blank then

            For i As Integer = 1 To 3

                Select Case i

                    Case 1

                        arrJournalEntries(Counter).TheDate = Sline
                        Sline = Reader.ReadLine


                    Case 2

                        arrJournalEntries(Counter).Title = Sline
                        Sline = Reader.ReadLine

                    Case 3

                        arrJournalEntries(Counter).JournalEntry = Sline
                        Sline = Reader.ReadLine

                End Select

            Next
        End If

        JournalDate = arrJournalEntries(Counter).TheDate

        Time = DateTimePicker1.Value

        MsgBox("Journal Date = " & JournalDate & vbCrLf & "Today's Date = " & Time)


        If Time = JournalDate Then

            JournalFound = True

        Else

            Counter += 1

            JournalFound = False

        End If

    Loop


    Reader.Close()

    Try

        If Sline Is Nothing Or JournalFound = False Then

            MsgBox("Your journal is now going to be created.")

            JournalDate = DateTimePicker1.Value
            JournalTitle = TitleTxt.Text
            JournalText = JournalTextRtxt.Text

            arrJournalEntries(Counter).TheDate = JournalDate
            arrJournalEntries(Counter).Title = JournalTitle
            arrJournalEntries(Counter).JournalEntry = JournalText

            Dim Writer As New StreamWriter(MyName & ".txt", True)

            Do Until (arrJournalEntries(Counter).TheDate = Nothing)

                Writer.WriteLine(arrJournalEntries(Counter).TheDate)
                Writer.WriteLine(arrJournalEntries(Counter).Title)
                Writer.WriteLine(arrJournalEntries(Counter).JournalEntry)


                Counter += 1

            Loop

            Writer.Close()


        End If

        If JournalFound = True Then

            MsgBox("Your journal is now going to be edited.")

            JournalDate = DateTimePicker1.Value
            JournalTitle = TitleTxt.Text
            JournalText = JournalTextRtxt.Text


            arrJournalEntries(Counter).TheDate = JournalDate
            arrJournalEntries(Counter).Title = JournalTitle
            arrJournalEntries(Counter).JournalEntry = JournalText


            Dim Writer As New StreamWriter(MyName & ".txt", True)

            Do Until (arrJournalEntries(Counter).TheDate = Nothing)

                Writer.WriteLine(arrJournalEntries(Counter).TheDate)
                Writer.WriteLine(arrJournalEntries(Counter).Title)
                Writer.WriteLine(arrJournalEntries(Counter).JournalEntry)


                Counter += 1

            Loop

            Writer.Close()


        End If

    Catch ex As Exception

        MessageBox.Show("An error has occured" & vbCrLf & vbCrLf & "Original Error:" & vbCrLf & ex.ToString)

    End Try



End Sub`

The problem that’s occuring is that it’s not only writing in the first time wrong. When it’s supposed to say it’s going to edit, it doesn’t, it just says creating. But it just adds on to the file. After pressing the button 3 times with the current date. and the Title being “Test title”, and the journal entry text being “Test text”. This is what occured.

Journal Entry Incorrect

It should just be

7/10/2012 3:52:08 PM

Test title

Test text

7/10/2012 3:52:08 PM

Test title

Test text

the whole way through. but of course if it’s the same date then it just overwrites it. So can anybody please help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:41:45+00:00Added an answer on June 7, 2026 at 7:41 am

    You are only filtering your array by the date, so it looks like you have an object with a date but no title or text:

    Do Until (arrJournalEntries(Counter).TheDate = Nothing)
    

    The “quick” fix:

    Do Until (arrJournalEntries(Counter).TheDate = Nothing)
      If arrJournalEntries(Counter).Title <> String.Empty Then
        Writer.WriteLine(arrJournalEntries(Counter).TheDate)
        Writer.WriteLine(arrJournalEntries(Counter).Title)
        Writer.WriteLine(arrJournalEntries(Counter).JournalEntry)
      End If
      Counter += 1
    Loop
    

    Do consider getting rid of the array and using a List(of JournalEntry) instead. Your code looks difficult to maintain in its current state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I have the following create action #posts_controller, nested resource under discussions def create
Okay so I have to create a radix sort for both unsigned ints and
Okay I have a list of devices where i can select which to edit.
Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay this question is very simple: I have a facebook page, and a website.
Okay, so I have my post.php page. If you are not logged in, you'll
Okay - I have a dilemma. So far my script converts page titles into
okay, i'm setting up a multi-user chat system. i have a messages table, that
Okay, I have GOT to be missing something totally rudimentary here. I have an
Okay, none of the previous questions I have seen with this error seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.