Results 1 to 6 of 6

Thread: Using a resource file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Fridley, MN, USA
    Posts
    19

    Post

    I have a resource file that contains two files, but i dont know how to run them, they are both "custom" and labeled 101 and 102. Any help is appreciated.

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    What type of files are stored in the resource file?

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    If it turns out that the res file contains strings, here is a routine you can use to get at them.
    Code:
    Function ResolveResString(ByVal resID As Integer, ParamArray vReplacements() As Variant) As String
    '-----------------------------------------------------------
    ' FUNCTION: ResolveResString
    ' Reads resource and replaces given macros with given values
    '
    ' Example, given a resource number 14:
    '    "Could not read '|1' in drive |2"
    '   The call
    '     ResolveResString(14, "|1", "TXTFILE.TXT", "|2", "A:")
    '   would return the string
    '     "Could not read 'TXTFILE.TXT' in drive A:"
    '
    ' IN: [resID] - resource identifier
    '     [vReplacements] - pairs of macro/replacement value
    '-----------------------------------------------------------
    '
        Dim nMacro As Integer
        Dim sResString As String
        
        sResString = LoadResString(resID)
        
        ' For each macro/value pair passed in...
        For nMacro = LBound(vReplacements) To UBound(vReplacements) Step 2
            Dim sMacro As String
            Dim sValue As String
            
            sMacro = vReplacements(nMacro)
            On Error GoTo MismatchedPairs
            sValue = vReplacements(nMacro + 1)
            On Error GoTo 0
            
            ' Replace all occurrences of sMacro with sValue
            Dim nPos As Integer
            Do
                nPos = InStr(sResString, sMacro)
                If nPos > 0 Then
                    sResString = Left$(sResString, nPos - 1) & sValue & Right$(sResString, Len(sResString) - Len(sMacro) - nPos + 1)
                End If
            Loop Until nPos = 0
        Next nMacro
        
        ResolveResString = sResString
        
        Exit Function
        
    MismatchedPairs:
        Resume Next
    End Function
    It allows the strings to have replaceable parameters. The following calls the above routine with a variable named resINTEGNOTFOUND (which could have a value of 101). In this case the string has 3 replaceable parameters.

    Code:
                MsgBox ResolveResString(resINTEGNOTFOUND, "|1", "Desired", "|2", gsDefIntegType1, "|3", sFirstIntegType), gnStyle, gsTitle

    ------------------
    Marty

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Fridley, MN, USA
    Posts
    19

    Post

    they are both .exe's.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Fridley, MN, USA
    Posts
    19

    Post

    I have no idea what that means Martin Liss

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Check out the Previous Post

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


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