I am using VB2 to learn the basics of VB. I used a VB2 text as a reference to answer the task at hand. This should be very easy but the code from the book did not work.
The question is to create a programme that will
a) Allow the user to enter a poem into a text box
b) Allow the user to save to file
c) On form load, Load the poem from the file into the text box.
It is C that I have trouble with. I manage to load the entire poem into a single string variable no problems. According to my book, using a variable (NL) holding these values "chr$(13) & chr$(10)" would force a new line so that the poem is not one long line.
This didn't work.
Here is the code I used:
Sub Form_Load ()
Dim Poem As String
Dim PoemLine As String
Dim count As Integer
Dim NL As String
NL = Chr$(13) & Chr$(10)
Open "a:\Poem.txt" For Input As #1
count = 1
Do Until (EOF(1) = True)
Input #1, PoemLine
PoemLine = PoemLine
'Poem = Poem & PoemLine
txtPoem = txtPoem + NL & PoemLine
count = count + 1
count = 0
'Me!txtPoem = Poem
This is the result I get in the text box:
This is line one of the poem This is line two of the poem This is line three of the poem This is line four of the poem
Except there are two black rectangles seperating each line.