Results 1 to 2 of 2

Thread: A better way to declare dozens of text constants?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    36

    A better way to declare dozens of text constants?

    Hi all, I have a small conundrum that could save me hours of work if I solve it.

    At the moment, I am declaring all of my text constants (for labels, descriptions etc) like so...

    Code:
    cLBL_OBJECT_RESOURCE = iniLang.GetString ("PropGrid", "cLBL_OBJECT_RESOURCE", "*Resource")
    where iniLang.getString is a method to retrieve the string from an ini file. I have literally dozens of these, so it's quite time consuming. This is only half of the job, the other half is applying them to the buttons etc (this example has 3 constants)...

    Code:
    .Item.Add(cLBL_SHOW_TERRAIN, YesNo.Yes, False, cGLOBALPROPERTIES, cLBL_SHOW_TERRAIN_DESC, True)
    Is there a better technique to use in .net? It needs to be dynamic, the text must come from a text file of some kind because I need to be able to allow others to edit the text strings. The ini file approach isn't the issue here (I know people have strong feelings on this topic!), it's the coding of dozens of constants.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: A better way to declare dozens of text constants?

    Use a RESX file and .NET localization. You don't have to create any language-specific resources if you don't want. Just the default resource file is fine.

    http://msdn2.microsoft.com/en-us/lib...d3(VS.80).aspx
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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