Search code examples
vb6embedded-resourceresource-files

Visual Basic 6 Command included on String Table


Here is the situation, I have this string table, in a .res file and I have some strings loaded into one of the forms, say Form1. On a form on I want to popup a message box with a message loaded from the string table using LoadResString(1234).

Is it possible that when Resource ID 1234 contains "This is testing vbNewline This is a new line!." that string will be loaded using the said function onto the message box (popup box)? I've tested it: It will also print out the "vbNewline" command and NOT parse it. Is there any other way to parse the said string making this kind of message ?

This is testing
This is new line!.

I wanted that kind of message to appear.


Solution

  • You are trying to put a VB constant in a String expression so it is treating it like text, you can try using the Replace Function ( I realize this is a .Net link but the signature is the same as the VB6 method) to remove your string and substitute the correct value something like this should work:

    MsgBox (Replace(LoadResString(1234), "vbNewLine", vbNewLine))
    

    or create a function like this:

    Public Function ParseNewLine(value As String) As String
        ParseNewLine = Replace(value, "vbNewLine", vbNewLine)
    End Function
    

    and call it like this:

    MsgBox (ParseNewLine(LoadResString(1234)))