Home > Software engineering > The tooltip text read commas between super end such as files, content should be assigned to a variab
The tooltip text read commas between super end such as files, content should be assigned to a variab
Time:09-26
The program is that
Private Sub Command1_Click () Dim id $, name $, price $, store $' declare variables attribute Open "fetch. TXT" For Input As # 1 The Do While Not EOF (1) Input # 1, id, name, price, and store the data into the 'four variables in Print id, name, price, output data store ' Loop Close # 1 MsgBox "complete" End Sub
This code, you want to read the file content but not normal "error", has a limitation: The text file you fetch. TXT last line can't end with "of", the newline character.
"Simple" sensory judgment, is after you open this file with notepad program, Its "at the end of the line" is not a blank line; You press the keyboard "Ctrl + End", behind the cursor "1", in 141021, flashing, rather than at the start of a blank line,
CodePudding user response:
Just run your code, and found that the result is: The last line can use "+ newline character at the end, that is the end of the file can have a" blank lines "; But if you press the return key, more add a blank line at the end of the file, would be a "super end as file" error,
CodePudding user response:
Private Sub Command1_Click () On the Error Resume Next Dim id $, name $, price $, store $' declare variables attribute Open "fetch. TXT" For Input As # 1 The Do While Not EOF (1) Input # 1, id, name, price, and store the data into the 'four variables in Print id, name, price, output data store ' Loop Close # 1 MsgBox "complete" End Sub