473,385 Members | 1,326 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,385 software developers and data experts.

Redefine data structures?

I suspect the answer is "no," but I thought I'd throw this out anyway.
My background is in languages that support redefintion in
datastructures, something that I've yet to figure out in VBA.

Is it possible redefine variables something like this in VBA:

Type BatchHeader1
RecType As String * 1
ServiceClassCd As String * 3
CompanyName As String * 16
end type

dim bh as BatchHeader1
dim strBig as string redefines bh

bh.Rectype = "A"
bh.ServiceClassCd = "BBB"
bh.CompanyName ="CCCCCCCCCCCCCCCC"

At this point, strBig would contain
"ABBBCCCCCCCCCCCCCCCC"
Thanks,
Mike
..

Mar 9 '06 #1
3 3517
On 9 Mar 2006 14:11:13 -0800, "mike" <mi**********@gmail.com> wrote:
I suspect the answer is "no," but I thought I'd throw this out anyway.
My background is in languages that support redefintion in
datastructures, something that I've yet to figure out in VBA.

Is it possible redefine variables something like this in VBA:

Type BatchHeader1
RecType As String * 1
ServiceClassCd As String * 3
CompanyName As String * 16
end type

dim bh as BatchHeader1
dim strBig as string redefines bh

bh.Rectype = "A"
bh.ServiceClassCd = "BBB"
bh.CompanyName ="CCCCCCCCCCCCCCCC"

At this point, strBig would contain
"ABBBCCCCCCCCCCCCCCCC"


strBig = bh.Rectype & bh.ServiceClassCd & bh.CompanyName
Wayne Gillespie
Gosford NSW Australia
Mar 9 '06 #2
The simplest thing you could do is to write a function (which I suspect
is what your redifinition thing is) to concatenate the elements of your
data structure:

bh.Rectype = "A"
bh.ServiceClassCd = "BBB"
bh.CompanyName ="CCCCCCCCCCCCCCCC"

Function concatElements(bh As BatchHeader1) As String
concatElements = bh.RectType & bh.ServiceClassCD & bh.CompanyName
End Function

strBig = concatElements(bh)

If you want to do something like

Dim strBig As String = bh

then you need to use an Object oriented version of VB like VB.Net. VBA
is not object oriented - does not support polymorphism, overloading, or
inheritance

HTH
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Mar 10 '06 #3
Thanks for your replies. I suspected there was no such thing, it's
just kind of surprising. I realize that the VB way is to concatenate
the individual components of the defined type to arrive at one large
string, but that kind of cripples its functionality.

There are a number of non-object traditional languages that support
redefinition, I've worked primarily with COBOL, Powerhouse and VAX
BAsic, so I suspect it's a limitation of VBA, rather than being an OE
vs non-OE thing.

Another data structure that seems to be "missing" in Access from my
perspective is the ability to sub-define items in table design. Both
COBOL and Powerhouse let you define a table item like this for example

TRANS-DATE ZONED UNSIGNED 8
_TRANS-DATE-ASCII CHARACTER 8
.TRANS-DATE-YEAR CHARACTER 4
.TRANS-DATE-MONTH CHARACTER 2
.TRANS-DATE-DAY CHARACTER 2

Zoned decimal is essentially ASCII, so a date defined as zoned
(TRANS-DATE) can be redefined as ASCII (TRANS-DATE-ASCII), which can be
broken into sub-items, indicated by the dot notation in Powerhouse.
COBOL is similar, and I seem to remember doing this is C as well. We
would typically define a date like this in Powerhouse to be able to
assign a numeric value, e.g. the system date, to TRANS-DATE, and be
able to reference it or it's components as ASCII. Alternately, computed
values, e.g., a date in an ensuing month or fiscal year, could be
assigned to the year, month, and day sub-items and referenced as a
numeric via TRANS-DATE, or as an entire ASCII date via
TRANS-DATE-ASCII.

Oh well, enough reminiscing about the past, back to the task at
hand....

Thanks again.
Rich P wrote:
The simplest thing you could do is to write a function (which I suspect
is what your redifinition thing is) to concatenate the elements of your
data structure:

bh.Rectype = "A"
bh.ServiceClassCd = "BBB"
bh.CompanyName ="CCCCCCCCCCCCCCCC"

Function concatElements(bh As BatchHeader1) As String
concatElements = bh.RectType & bh.ServiceClassCD & bh.CompanyName
End Function

strBig = concatElements(bh)

If you want to do something like

Dim strBig As String = bh

then you need to use an Object oriented version of VB like VB.Net. VBA
is not object oriented - does not support polymorphism, overloading, or
inheritance

HTH
Rich

*** Sent via Developersdex http://www.developersdex.com ***


Mar 10 '06 #4

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

Similar topics

0
by: Michael Bane | last post by:
Am I right in thinking that... 1) in <redefine> I can either extend OR restrict a type but not both? 2) in <redefine> it's not possible to change a type from say <xs:string> to <xs:integer>? ...
2
by: BillD | last post by:
I'm trying to derive a schema from a base schema. I want to redefine a "group" from the base schema in my derived schema in order to add more options to the "choice" aggregate (see schema1.xsd...
1
by: Cat | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm getting a validation error when I try to restrict the content of nested groups with xs:redefine whereas the same restriction on xs:element's...
3
by: junlia | last post by:
We are using ACORD xml schema standard, and we need to add to it, so we choose to redefine ACORD xml schema. One of the problems that I ran into is how to add some values to an emumerated list. ...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
11
by: efrat | last post by:
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure...
2
by: ERingmae | last post by:
Hi, The environment is .NET 2.0, the language is C# and the problem is reading XSD file with xs:redefine section correctly to a XMLDataDocument.DataSet. What I am trying to do: I am trying...
29
by: Mik0b0 | last post by:
Hallo to everyone. This fall I am going to start data structures as a part of C language course. The problem is I could not find any satisfying tutorial about structures in C. There are plenty of...
1
by: jaarmstr | last post by:
hello, i am working on an assignment so i wont be getting into specifics i just want some general help. so here is the situation... i have mutliple drivers. driver one runs a BST insert and search...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.