Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2003, 04:24 PM
Authorized User
 
Join Date: Jun 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Building Objects

Ok. I have created a DataType that I want to use. Here is the code:

Public Type TTRansAE
    Body As String * 24
    CD As OutboundTransactionType
    BeginStamp As String * 10
    EndStamp As String * 10
    ExceptionCode As String * 1
    AddDelete As String * 1
End Type

CD is defined as OutboundTransactionType. This is a Public Enum (1-12)

So this works. I am able to build my object and send it to my Processing Function. In my processing function I am sending out messages over a wireless network. The problem is I have to send it to my API as a string. So I have to concantenate all values of the object into a string.
string = Trans.Body&Trans.CA&Trans.BeginStamp& ...etc.
Except, I want to build this into its own routine so that I can pass it different transaction types that may have more or less properties. So I was trying to add a "Count" property of the Type that I can set it be the number of properties. (So I can loop). Except you can't reference properties of a type by an index (or counter). So do I have to build a Collection? I was thinking an Attributes collection that would have the Key/Value combo for each property and is accessible through an indexed value.

Transaction.Attributes(0).value = "Test" would be the same as
Transaction.Attributes("Body").value = "Test" would be the same as
Transaction.Body = "Test".

Am I completely off base? Is this possible?:(
 
Old June 10th, 2003, 08:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One solution I see is to define a ITransaction class, and change
your TTransAE into a class that implements ITransaction.
ITransaction will have a method like:
public property get TransString() as String

All new transaction types will implement ITransaction and you
can put all them into a collection that you can use like this:

dim IT as ITransaction
for each IT in myCollection
  SendMessage IT.TransString
next

Was I clear enough?

Marco





Similar Threads
Thread Thread Starter Forum Replies Last Post
Query building anjurenjith SQL Language 0 August 2nd, 2007 05:07 AM
Chapter 10 - building objects kscase BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 5 April 23rd, 2007 04:55 AM
Building an E-Shop Varg_88 Beginning PHP 0 March 15th, 2006 05:25 AM
Building JK2 jakawan BOOK: Professional Apache Tomcat 1 December 18th, 2004 02:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.