October 2009
M T W T F S S
    Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Categories

  • [+]ASP.NET (7) 
  • [+]C# (87) 
  • [+]C++ (13) 
  • [+]Delphi (20) 
  • [+]JavaScript (24) 
  • [+]Regular Expressions (7) 
  • [+]SQL (13) 
  • [—]VB (100) 
  • [+]VB.NET (4) 

Online

Users: 8 Guests
  • Loading...


    Loading...

    Login






    Register | Lost password?

    Register





    A password will be mailed to you.
    Log in | Lost password?

    Retrieve password





    A confirmation mail will be sent to your e-mail address.
    Log in | Register
  • Reads resource and replaces given macros with given values

    '-----------------------------------------------------------
    ' 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
    '     [varReplacements] - pairs of macro/replacement value
    '-----------------------------------------------------------
    '
    Public Function ResolveResString(ByVal resID As Integer, ParamArray varReplacements() As Variant) As String
        Dim intMacro As Integer
        Dim strResString As String
    
        strResString = LoadResString(resID)
    
        ' For each macro/value pair passed in...
        For intMacro = LBound(varReplacements) To UBound(varReplacements) Step 2
            Dim strMacro As String
            Dim strValue As String
    
            strMacro = varReplacements(intMacro)
            On Error GoTo MismatchedPairs
            strValue = varReplacements(intMacro + 1)
            On Error GoTo 0
    
            ' Replace all occurrences of strMacro with strValue
            Dim intPos As Integer
            Do
                intPos = InStr(strResString, strMacro)
                If intPos > 0 Then
                    strResString = Left$(strResString, intPos - 1) & strValue & Right$(strResString, Len(strResString) - Len(strMacro) - intPos + 1)
                End If
            Loop Until intPos = 0
        Next intMacro
    
        ResolveResString = strResString
    
        Exit Function
    
    MismatchedPairs:
        Resume Next
    End Function
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

    Spam Protection by WP-SpamFree Plugin