|
-
May 7th, 2000, 12:33 AM
#1
Thread Starter
Member
Ok, I have a file listbox and and a multiline textbox and i want a text file to go into the textbox, but some of the files I click on are too big and it shows the Runtime error 62
Input past end of file message. I wanted to be able to make it show my own error message, but it shows my error message on everything now, wether there is an error or not. here is my code:
[code]
Private Sub File1_Click()
On Error GoTo Ermsg
Open File1.Path & "\" & File1.FileName For Input As #1
Text1.Text = Input(LOF(1), 1)
Close #1
Ermsg:
On Error Resume Next
If MsgBox("Error, Either the file you have selected is too big or is corrupted. Please select another.", vbCritical, "Error!") = vbOK Then Beep
End Sub
What it wrong?
[Edited by HoSs on 05-07-2000 at 01:34 PM]
Charlie Staton
14 y/o
I don't smoke, I don't drink, and I don't assosciate with pokemon.
-
May 7th, 2000, 12:44 AM
#2
You have to exit the sub if no error is raised.
Code:
Private Sub File1_Click()
On Error GoTo Ermsg
Open File1.Path & "\" & File1.FileName For Input As #1
Text1.Text = Input(LOF(1), 1)
Close #1
Exit Sub '<-- Add this line
Ermsg:
On Error Resume Next
If MsgBox("Error, Either the file you have selected is" _
& " too big or is corrupted. Please select another.", _
vbCritical, "Error!") = vbOK Then Beep
End Sub
Good luck!
-
May 7th, 2000, 12:50 AM
#3
Thread Starter
Member
it still dosn't work. Sorry.
Charlie Staton
14 y/o
I don't smoke, I don't drink, and I don't assosciate with pokemon.
-
May 7th, 2000, 01:05 AM
#4
transcendental analytic
Input's often pasts end, and usually for beginners. This time, it's because you're file isn't textbased, so input will search until it jumps out of the file generating this error. Now instead you should open in binary and use GET to fetch the content of the file.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 7th, 2000, 01:38 AM
#5
Thread Starter
Member
Thanks for your help. I got it figured out now!
Charlie Staton
14 y/o
I don't smoke, I don't drink, and I don't assosciate with pokemon.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|