Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Files

Visual Basic 4 / 5 / 6

  • Please log in to reply
No replies to this topic

#1 Bujbuj

Bujbuj

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 435 posts
  • Programming Language:C
  • Learning:Java, C#, (Visual) Basic, JavaScript, Assembly

Posted 23 November 2010 - 11:14 AM

Hey all, I need some help quickly. I'm doing a VB5 project with a friend, but he's got a virus on his flash drive so it was deleted. I managed it to get an older version on it, and I have to finish it tomorrow.

Almost everything is ready, but speed. I have 3 radio buttons. The user sets the desired speed using them. What I want to do is to remember the choice using the file "conf". Here's the code -

If Dir("conf") <> "" Then
Open "conf" For Input As #1
Line Input #1, str
MsgBox str
Else
Set FSO = CreateObject("Scripting.FileSystemObject")
Set newFIle = FSO.CreateTextFile("conf", True, False)
FSO.Write "50"
End If

I want it to be 100% foolproof. If the user deleted the value from the file, a fatal error would occur and kill the program because the file exist, so it tries to read the value and fails. A problem. I'd use Try Catch, but it's VB5. I've heard something about on error goto, but I can't understand how it works. Basically I need to check if the first line of the file is "50", "70" or "100", and if it is read it. If not, Write "70" to the file's first line. Can someone please explain me how?

Thanks a lot to anyone who helps.
Mike.
  • 0

Posted Image
There is no problem that cannot be solved by the use of high explosives.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download