Results 1 to 6 of 6

Thread: Runtime Error 91...aaargh!!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    81
    Hello everyone,

    I made a simple little app to start me off making a program to get rid of Happy99.exe from some of my friends' PCs. One of the little functions I wanted this program to perform was to check the liste.ska file that stores the e-mail addresses for all of the people that the trojan has been sent to. It's just a text file, and I used "C:\users\webs.txt" to test. So in the little app I made I added a richtextbox, made a referrence to "Microsoft Scripting Runtime" and wrote the code, and it worked. I tried it later and it didn't. I rewrote it and it still didn't work - the reason being some bizarre Runtime error - 91 - object variable or with block variable not set...here's the code:-

    Dim FSys As FileSystemObject
    Dim InStream As TextStream

    Private Sub cmdRead_onClick()
    Set InStream = FSys.OpenTextFile("C:\users\webs.txt")
    rtbText.Text = InStream
    End Sub

    Now I'm probably totally missing the plot here and someone's going to come along and tell me so, but it's the
    "Set InStream = FSys.OpenTextFile("C:\users\webs.txt")" line that's causing the problems and I don't know why.

    Any help would be greatly appreciated :-)

    Thanx
    Sam

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    Hi, Sam.

    Did you set the Reference to Microsoft Scripting Runtime?

    Larisa

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    81
    That I did

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    Hi, Sam.

    I took a sample code from Microsoft and modified a little, it doesn't give me any errors.

    Private Sub Command1_Click()

    Dim fso As New FileSystemObject
    Dim ts As TextStream
    Set ts = fso.OpenTextFile(Environ("windir") & "\system.ini", ForReading)
    Do While Not ts.AtEndOfStream
    RichTextBox1.Text = ts.ReadAll

    Loop
    ts.Close
    End Sub

    Larisa




  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Thank you!!!

    Larisa,

    just as I was getting ready to shoot myself in the head when I couldn't work out the differences between the declarations made by you and Microsoft and those made by me to begin with. Then I noticed that I'd written:

    Dim FSys As FileSystemObject

    instead of

    Dim FSys As New FileSystemObject

    as you had written.

    This pleases me no end since my Happy99 cure is now complete!!!

    Thank you soooo much for all your help,

    Sam :-D

  6. #6
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    Sam, you are very welcome!

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