PDA

Click to See Complete Forum and Search --> : Using a resource file


VB Starter
Dec 5th, 1999, 06:09 AM
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.

Clunietp
Dec 5th, 1999, 07:55 AM
What type of files are stored in the resource file?

MartinLiss
Dec 5th, 1999, 08:04 AM
If it turns out that the res file contains strings, here is a routine you can use to get at them.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.

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


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

VB Starter
Dec 5th, 1999, 08:59 AM
they are both .exe's.

VB Starter
Dec 5th, 1999, 09:02 AM
I have no idea what that means Martin Liss

Serge
Dec 5th, 1999, 06:05 PM
Check out the Previous Post (http://www.vb-world.net/ubb/Forum1/HTML/011328.html)

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

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)