Results 1 to 15 of 15

Thread: Computer Diary. (Edited)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Computer Diary. (Edited)

    Okay, sorry about all that.

    I have 100 text documents. They are all located in E:\The List\Text, with the names 1.txt, 2.txt ... 100.txt

    I want to make a program in visual basic, where you can select from a calender a date, and it will load up a form. On that form, depending on the date/event, it will open one of the text files, so it's visible on the form (so you don't read it in Notepad, but on the Visual Basic form itself). Also, these text documents would be longer than, say, a monitor's height, so I would need to have a scroll bar.

    Could somebody help?
    Last edited by yatesell; Apr 17th, 2006 at 08:06 PM. Reason: Making more sense. I hope.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Computer Diary. (Edited)

    VB Code:
    1. Dim BuffData As String
    2. Dim Data As String
    3. Dim Selected As Integer
    4. On Error GoTo ErrParse
    5. Selected = 1
    6.  
    7.  
    8. Open "E:\The List\Text\" & Selected & ".txt" For Input As #1
    9. Do Until EOF(1)
    10.     Input #1, BuffData
    11.     If Len(Data) <> 0 Then Data = Data & vbCrLf
    12.     Data = Data & BuffData
    13. Loop
    14. Text1.Text = Data
    15. Close #1
    16. Exit Sub
    17.  
    18. ErrParse:
    19. MsgBox Error
    Change the value of 'Selected' depending on which file you wish to open

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    Thank you.
    However, it says "Object Required" when I click it.

  4. #4
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Computer Diary. (Edited)

    What line is highlighted when that error appears?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    It comes up on the message box. I put all that coding into a command button (just to make sure it works etc), and when I run the program, and click the button, a message box comes up saying "Object Required".

    Then, if I click it again, it says "File Already Open".

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Computer Diary. (Edited)

    Have you added the Textbox to the form. Add a Text box, use the default name, set the multiline property to true and scrollbars property to both. Then run the code again.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  7. #7
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Computer Diary. (Edited)

    After the error comes up, a line of your code should be highlighted.
    I'm guessing it's the
    VB Code:
    1. Text1.Text = Data
    line. Is your textbox named Text1 ?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    Oh.

    I'm sorry, that's probably it. I'm very tired, and rubbish at Visual Basic. I'll check now.

    Thank you so much, that works now. How can I replace the value "Selected" with, say, the value of a text box? (So you can change which file opens)


    Oh never mind, thanks. I've done it.
    I'm going to leave this unresolved for a day or so, incase I have any more problems.

    Thanks everyone.
    Last edited by yatesell; Apr 18th, 2006 at 08:04 AM.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    I now have 101 forms. FrmMain, then Form1, Form2 ... Form100.

    What's the code for a Combo box, so I can select the number of the form, to load it?
    Say, if I select 20 from the combo, it will load Form20.

  10. #10
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Computer Diary. (Edited)

    Why load different forms? You could just load the same form with different data.
    Basically change 'Selected' to a global variable and then when the user selects a number, 'Selected' will become that number and then you load Form1 which will open the textfile using Selected & ".txt"
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    Because I wanted to change the background, and title, of it all.

    Basically, I'm doing 100 different things, and on different days. These events (Say, "Do X") will appear on the calender, and the combo box. If you select it, the event "Do X" will load in a form, and it will have a description of it, and a diary, and stuff.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    I'm sorry to be a mega pain (I'm sure I'm going to get banned soon), but can you help me with this calender (and I'll deal with the combo box later).

    I have a calendar (Calendar1), and a timer (Timer1). I've put the code as:

    VB Code:
    1. Private Sub Timer1_Timer()
    2. If Calendar1.Value = 17 / 4 / 2006 Then
    3.     Form1.Visible = True
    4. End If
    5. End Sub

    I would have thougth that would have worked (If you click on the 17th of April, 2006, form1 would load). What have I done wrong?

  13. #13
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Computer Diary. (Edited)

    You are not putting the value in inverted commas, so it is doing 17 ÷ 4 ÷ 2006.
    You want it to be
    VB Code:
    1. Calendar1.Value = "17 / 4 / 2006" Then
    or something along those lines
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    16

    Re: Computer Diary. (Edited)

    Thank you so much.

    How do I put text into one of the calender date boxes?

  15. #15
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Computer Diary. (Edited)

    No problem, please consider adding to my reputation if I helped out!
    I'm not sure how to put text in the date boxes, I don't normally work with the calendar. Sorry.
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width