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 5 18963
> 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(CombinedA rray, Delimiter)
Rick
"Adam Parkin" <pz*****@hotmai l.com> wrote in message
news:ho78f.6239 5$Io.5074@clgrp s13... 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(1 01)
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!
Steve Gerrard wrote: 7. To use a string, use code like this:
Private Sub Command1_Click( ) Dim S As String
S = LoadResString(1 01) 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
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 CombinedArra y = Join(YourArray, Delimiter)
String to Array ============== === Dim YourArray() As String Dim Delimiter As String Dim CombinedArray As String Delimiter = vbTab YourArray = Split(CombinedA rray, Delimiter)
Sweet, I didn't know VB had Perl-like split & join functions. Thanks!
Adam
> >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 CombinedArra y = Join(YourArray, Delimiter)
String to Array ============== === Dim YourArray() As String Dim Delimiter As String Dim CombinedArray As String Delimiter = vbTab YourArray = Split(CombinedA rray, Delimiter) Sweet, I didn't know VB had Perl-like split & join functions.
Thanks!
Prior to Version 6, it didn't.
Rick This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 far, it
works great (after having a bit of heartache about .Dispose() ).
Now, I need a certain part of the class file to run through many times and
|
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
==> .txt files from .resources or .resx files.
==> .resources files from text or .resx files.
|
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 following code to retrieve resources:
This code is in the TextResource.vb file:
Public Class TextResource
Private objResourceManager As ResourceManager
|
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 base classes. A base class
includes this property (among others...;-)):
|
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 this adds a huge
performance boost in the application but I don't understand why. Is
there something to this?
Bill
| |
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 problem making the dll.
I am running into problems using it.
I am attempting to use the resource manager to get the values from the dll
and update the controls appropriately.
|
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 search resource file for this string id.
After that I need to return translated string from other resouce file ?
Is this best idea?
Where to find sample code which implements this ?
|
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!
|
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 being able to retreive
contents for use inside program.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |