Question about handling multiple FileSystemObjects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alord
    New Member
    • Mar 2009
    • 3

    Question about handling multiple FileSystemObjects

    Folks,
    Looking for a little advice on how to get this portion of my program working. I am developing a terminal emulation program to help us out at work. It is using multiple winsock controls to connect to various devices. As well, I wish to keep log files for each interaction. I had initially designed this using the FileSystemsObje ct and then using the OpenTextFile method. Where I am falling down is how to keep track of the textstream objects that will be created. I had thought of just creating a listbox (not visible to the user) to just store the textstream handle in it but this does not work. When you try to use the string that was stored in a .Write method it bombs because it is expecting a textstream object, not a string. I know I may not have explaind this very well but I am really open for further discussion on this. I am at a standstill. Below is a small code snip-it to give a little idea of where I was going.....

    'Open the log file for either 'Overwrite' or 'Append'
    If (StrComp("Overw rite", retString, vbTextCompare) = 0) Then
    Set fs = CreateObject("S cripting.FileSy stemObject")
    log_handle = "log_handle " & Str(activeTab)
    lstFileNumArray .List(CInt(lstC ontrolArray.Lis t(activeTab))) = log_handle
    Set log_handle = fs.OpenTextFile (strLogFile, ForWriting, True)

    ElseIf (StrComp("Appen d", retString, vbTextCompare) = 0) Then
    Set fs = CreateObject("S cripting.FileSy stemObject")
    log_handle = "log_handle _" & Str(activeTab)
    lstFileNumArray .List(CInt(lstC ontrolArray.Lis t(activeTab))) = log_handle
    Set log_handle = fs.OpenTextFile (strLogFile, ForAppending, True)
    Else
    MsgBox "Can't open log file " & strLogFile
    End If
  • vdraceil
    New Member
    • Jul 2007
    • 236

    #2
    Yes,'fs.OpenTex tFile(strLogFil e, ForWriting, True)' will return a textstream,so 'log_handle'-the one which receives the return value must be a textstream and not a string.
    'Dim log_handle as textstream' would do,i suppose.
    If you have so much of textstreams to use,try an array.
    'Dim log_handle(25) as textstream'
    I dont know if it would work,but try.
    Is this what you want?Have i got you correctly?

    Comment

    • alord
      New Member
      • Mar 2009
      • 3

      #3
      vdraceil,
      Thanks for the reply..... I am realy stuck here. I tried what you advised last night but it doesn't work. VB fired off an error when I tried to run it because you can't assign a teststream to an array. Any other thoughts?

      Thanks!

      Comment

      • alord
        New Member
        • Mar 2009
        • 3

        #4
        vdraceil,
        Ok, I think I have found out how to fix it. Instead of defining log_handle as an array of textstreams I just defined it as an array of type variant. It does seem to be working now. I will finish incorporating this idea and then test the heck out of it.

        I cant thank you enough for the idea!!!!!

        Comment

        Working...