473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Resource files and string arrays

Hello all, I am seeking some help with the following problem. I'm
working on an application where I have a resource file, and in this
resource file what I want to store is a list of file names (that is,
essentially a string array).

The potential solutions I see are:

1) Convert the string array into one big string with each element
separated by some special value, store that string into the resource
file's string table as a single entry, and then when I load the string
from the resource file parse it into a regular string array. The
problem with this is the obvious kludgy-ness of having to generate the
string, and then re-parse it whenever I want to read it from the
resource file. But its certainly doable.

2) To make a custom resource, and store the string array as a custom
resource, and re-load it back into my application. This seems the more
elegant solution, but I have no idea how to go about doing this. I
found a tutorial online to do something similar with an array of longs
via the CopyMemory API call, but the sample code caused VB to crash on
me (and I want a solution that's not buggy/unstable).

3) To use an external file to my application. This is however
unacceptable for my specific application.

Any suggestions/tips would be appreciated.

Thanks,

Adam
Oct 27 '05 #1
5 18908
> 1) Convert the string array into one big string with each
element
separated by some special value, store that string into the resource file's string table as a single entry, and then when I load the string from the resource file parse it into a regular string array. The problem with this is the obvious kludgy-ness of having to generate the string, and then re-parse it whenever I want to read it from the
resource file. But its certainly doable.


I've not worked with Resource File personally, so I can't help you
out with questions related to it directly. However, combining a
one-dimensional array into a single String and recovering the
array back again from the String are very simple things to do in
VB6.

Array to String
================
Dim YourArray() As String
Dim Delimiter As String
Dim CombinedArray As String
Delimiter = vbTab
CombinedArray = Join(YourArray, Delimiter)

String to Array
=================
Dim YourArray() As String
Dim Delimiter As String
Dim CombinedArray As String
Delimiter = vbTab
YourArray = Split(CombinedArray, Delimiter)

Rick
Oct 27 '05 #2

"Adam Parkin" <pz*****@hotmail.com> wrote in message
news:ho78f.62395$Io.5074@clgrps13...
The potential solutions I see are:

2) To make a custom resource, and store the string array as a custom resource,
and re-load it back into my application. This seems the more elegant
solution, but I have no idea how to go about doing this.


1. Activate the Resource Editor, by going to Add-Ins, Add In Manager... Find VB
6 Resource Editor in the list, and check the Loaded/Unloaded checkbox. Close the
manager form.

2. Click on Tools, Resource Editor.

3. In the resource editor, click the "abc" button, with tooltip "Edit String
Tables..."

4. For ID 101, enter "First One". Press Enter. For ID 102, enter "Second One".
etc.

5. Close the string editor. Click the Save button in the resource editor. Use
any file name you like.

6. This will add a resource file to your project, listed under "Related
Documents". It will be compiled into your executable.

7. To use a string, use code like this:

Private Sub Command1_Click()
Dim S As String

S = LoadResString(101)
MsgBox S

End Sub

If all is well, you should get the message "First One".

The big deal with string tables is that you can add a second string table,
selecting "French (France)" as the locale ID. Then for 101, you enter "Premier".
If users run your program in France, they will get the message "Premier" instead
of "First One". Automagically!

Oct 28 '05 #3
Steve Gerrard wrote:
7. To use a string, use code like this:

Private Sub Command1_Click()
Dim S As String

S = LoadResString(101)
MsgBox S

End Sub

If all is well, you should get the message "First One".

The big deal with string tables is that you can add a second string table,
selecting "French (France)" as the locale ID. Then for 101, you enter "Premier".
If users run your program in France, they will get the message "Premier" instead
of "First One". Automagically!

Thanks, but that part I already knew. The problem with this version is
that if I have 100 entries in the array, I have to create 100 strings in
the table, which isn't a problem code-size wise but is certainly a data
entry pain in the #@$@.

Adam
Oct 28 '05 #4
Rick Rothstein [MVP - Visual Basic] wrote:
I've not worked with Resource File personally, so I can't help you
out with questions related to it directly. However, combining a
one-dimensional array into a single String and recovering the
array back again from the String are very simple things to do in
VB6.

Array to String
================
Dim YourArray() As String
Dim Delimiter As String
Dim CombinedArray As String
Delimiter = vbTab
CombinedArray = Join(YourArray, Delimiter)

String to Array
=================
Dim YourArray() As String
Dim Delimiter As String
Dim CombinedArray As String
Delimiter = vbTab
YourArray = Split(CombinedArray, Delimiter)

Sweet, I didn't know VB had Perl-like split & join functions. Thanks!

Adam
Oct 28 '05 #5
> >I've not worked with Resource File personally, so I can't help
you
out with questions related to it directly. However, combining a
one-dimensional array into a single String and recovering the
array back again from the String are very simple things to do inVB6.

Array to String
================
Dim YourArray() As String
Dim Delimiter As String
Dim CombinedArray As String
Delimiter = vbTab
CombinedArray = Join(YourArray, Delimiter)

String to Array
=================
Dim YourArray() As String
Dim Delimiter As String
Dim CombinedArray As String
Delimiter = vbTab
YourArray = Split(CombinedArray, Delimiter)

Sweet, I didn't know VB had Perl-like split & join functions.

Thanks!

Prior to Version 6, it didn't.

Rick
Oct 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David | last post by:
Hi all, I am fairly new to C#. so go easy on me :-) Anyhow, I have a class file that I have set up properties and a method. I am calling this class file directly from and aspx.cs file. So...
1
by: Namratha Shah \(Nasha\) | last post by:
Hi All, This is a resource file generation tool which converts an xml based resource formats to .net resource file i.e. (.resources) and vice-versa. Today we will see how we will generate ...
0
by: Patrick | last post by:
Hi all, I have a very strange problem with my resource files. I have build an applicatie which uses resource files, but for some reason only the default language works as it should. I use the...
2
by: Fredrik Rodin | last post by:
All, I'm having problems with my resource manager in ASP.NET 2.0 after conversion from ASP.NET 1.1. Here is a background: In ASP.NET 1.1 All my user controls and aspx pages inherit from...
4
by: dwyer.bill | last post by:
My boss insists that whenever we use a string we place it in a resource file every single time. This goes for error string that are displayed through a message box, constants, ect. He claims that...
1
by: Bill Mell | last post by:
I would like to use compiled resource files in my web application that are not related to localization. The idea is to have a dll with resources that can be accessed by the website. I have no...
2
by: Andrus | last post by:
I have resource files in different languages created by VCS 2005 Express. I want to use those files to translate reports at runtime. I have text to be translated as string. I think I need to...
12
by: TS | last post by:
i have a need to possibly enable mutli language support. What benefit do i get by using a resource file instead of a custom xml solution? thanks!
7
by: Ivan | last post by:
Hello group. Here is what I like to do. #1. Add ".SQL" file to project #2. Being able to load contents of this file into string variable. So, I want .SQL to be compiled into executable and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.