Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 20th, 2006, 12:36 PM
Registered User
 
Join Date: Oct 2006
Location: Faridabad, Haryana, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Resource File

Dear All

I want to create a resource file in Vb 6.0 with multiple string messges and i want to use these message in my apllication with message boxes.

So pls advice me how can i create resource file and how can i retreive these messges from that resource file.

Regards
Kapil Kumar

Reply With Quote
  #2 (permalink)  
Old October 20th, 2006, 02:34 PM
Authorized User
Points: 312, Level: 6
Points: 312, Level: 6 Points: 312, Level: 6 Points: 312, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2006
Location: Orpington, Kent, United Kingdom.
Posts: 73
Thanks: 1
Thanked 1 Time in 1 Post
Default

Kapil, I'm not sure exactly what you wish to do, but ity sounds as if you wish to open and read in an external file, with all the strings you require sequentially. Depending on many strings yo need to use, it might be just as weel to create the strings within the sub-routine, and pass them to the message boxes when required. Any help ?

Reply With Quote
  #3 (permalink)  
Old October 20th, 2006, 05:57 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are several ways to go about using a RES file in vb.

The way that I do typically do it is to create an RC file (that is, a text file that with the extension of rc) and then compile that into a RES file using the rc.exe utility that comes with Visual Studio 6 (and probably with VB6 as well if that is all you got).

The compiled .res file can then be added to your project, and you can access the strings in the res file using the LoadResString intrinsic VB6 function like this:

Debug.Print LoadResString(1)

Another way to deal with this is to use the VB6 Resource Editor add-in, which you should be able to add to your IDE using the Add-In Manager. This tool lets you create and edit a res file for your project directly without using an rc file. This is perhaps a bit easier than making the .rc text file and then compiling it to an .res file, but it is also less flexible.

Because I have to deal with numerous languages and a lot of various translations, I do not include the res file directly in my main application, but rather compile it into an external dll which can then be used by the main application. This allows me to have more than one res file available to the application, since in VB a project can have only one RES file directly associated with it, and allows me to change languages on the fly, so to speak. Another advantage to the method I use is that I can send the text file to a customer so they can create their own translations using any text editor.

The format of the rc file is important, and here is an example of a simple rc file:

// String Table for US English

STRINGTABLE DISCARDABLE
BEGIN
// Menu Items
100,"&Note"
101,"&New Note"
102,"&Edit Note"
103,"&Delete Note"
End

As a side note, remember that the maximum ID that a resource can have is 65535. That is plenty of strings for almost any app, and you can compile as many strings as you need into external dlls as I described above if you have such a need.

One thing I usually do is create an enum to map the resource ids. This way my code will have the human readable enum value instead of just "magic" numbers in the code. Make sense?

Anyway - there is more to this than can be quickly explained here, but this is a start for you.

Woody Z http://www.learntoprogramnow.com
Reply With Quote
  #4 (permalink)  
Old October 23rd, 2006, 04:32 AM
Registered User
 
Join Date: Oct 2006
Location: Faridabad, Haryana, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear All
Thanks for ur mails.

I got my answer for using .res files in VB 6.0.

Regards
Kapil Kumar


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Text file from Resource folder balesh.mind ASP.NET 3.5 Basics 1 November 14th, 2008 06:54 AM
meta:resource key in skin file manoj.aggarwal ASP.NET 2.0 Professional 4 August 9th, 2007 08:37 AM
how to read Bitmap from Resource file ashu_from_india .NET Framework 2.0 2 July 6th, 2007 05:54 AM
how to make a resource file in a Win application richarding C# 1 January 20th, 2006 02:59 AM
How can we use a resource file in vb.net Amrit ADO.NET 2 April 11th, 2005 02:46 PM



All times are GMT -4. The time now is 06:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.