473,837 Members | 1,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

defining a flexible PROPERTY

I use one of 2 arrays dependent on the country.

Rather than say:
if exchangeID = 1 then
dim myPlaceBets() as As UK.exchange.Pla ceBets
many statements
myPlaceBetsReq. bets = myPlaceBets
else
dim myPlaceBets() As AU.exchange.Pla ceBets
many statements
myPlaceBetsReq. bets = myPlaceBets
end if

I want to say is something like this:

Public Property myPlaceBets() As
BF4_1_rel_13_4. betfair.UK.exch ange.PlaceBets OR as
BF4_1_rel_13_4. betfair.AU.exch ange.PlaceBets

Not being able to do this I said

Public Property myPlaceBets() As Object

Defining the property as Object, while the correct array is returned, it
fails in use with the message:

Conversion from type 'Object()' to type 'PlaceBets()' is not valid. Here's
the Property.

Private _myPlaceBetsUK(-1) As UK.exchange.Pla ceBets
Private _myPlaceBetsAU(-1) As AU.exchange.Pla ceBets
Private _PlaceBets() = {_myPlaceBetsUK , _myPlaceBetsAU}

Public Property myPlaceBets() As Object
Get
Return _PlaceBets(exch angeId - 1)
End Get
Set(ByVal Value As Object)
_PlaceBets(exch angeId - 1) = Value
End Set
End Property

Any help would be appreciated.

Gadya
Mar 8 '07 #1
2 1682
Do UK And AU exposes the same methods ?

See OOP details at :
http://msdn2.microsoft.com/en-us/lib...56(VS.71).aspx (in particular
4.3/4.5 or 4.4).

Basically 4.3 is :
- your classes share come common code. You use an Ancestor class that
implements common behavior. The UK and AU inherits from this common ancestor
their common behavior and can specialize themselves. Using an As Ancestor
array you'll be able to use either UK and AU (as you have the guarantee that
methods exposed by thr Ancestor are also available in UK /AU as they inherit
from Ancestor).

If they have nothing related but still exposes the same classe methodfs you
could see 4.4 that sjust allows to guarantee that they both exposes the same
methods. You can then use an As IMyInterface array.

This is the a very qucik overview. Your best bet is to read on a tutorial
about OOP.

--
Patrice

"gadya" <ga***@discussi ons.microsoft.c oma écrit dans le message de news:
08************* *************** **...icrosof t.com...
>I use one of 2 arrays dependent on the country.

Rather than say:
if exchangeID = 1 then
dim myPlaceBets() as As UK.exchange.Pla ceBets
many statements
myPlaceBetsReq. bets = myPlaceBets
else
dim myPlaceBets() As AU.exchange.Pla ceBets
many statements
myPlaceBetsReq. bets = myPlaceBets
end if

I want to say is something like this:

Public Property myPlaceBets() As
BF4_1_rel_13_4. betfair.UK.exch ange.PlaceBets OR as
BF4_1_rel_13_4. betfair.AU.exch ange.PlaceBets

Not being able to do this I said

Public Property myPlaceBets() As Object

Defining the property as Object, while the correct array is returned, it
fails in use with the message:

Conversion from type 'Object()' to type 'PlaceBets()' is not valid. Here's
the Property.

Private _myPlaceBetsUK(-1) As UK.exchange.Pla ceBets
Private _myPlaceBetsAU(-1) As AU.exchange.Pla ceBets
Private _PlaceBets() = {_myPlaceBetsUK , _myPlaceBetsAU}

Public Property myPlaceBets() As Object
Get
Return _PlaceBets(exch angeId - 1)
End Get
Set(ByVal Value As Object)
_PlaceBets(exch angeId - 1) = Value
End Set
End Property

Any help would be appreciated.

Gadya


Mar 8 '07 #2
Patrice thanks for your reply.

Do UK And AU exposes the same methods ?

Yes, they do.

As to ancestors; they both inherit from system.object
Firstly here are the properties

' an arrray of bets
Private _myPlaceBetsUK(-1) As BF4_1_rel_13_4. betfair.uk.exch ange.PlaceBets
Private _myPlaceBetsAU(-1) As BF4_1_rel_13_4. betfair.au.exch ange.PlaceBets
Private _PlaceBets() = {_myPlaceBetsUK , _myPlaceBetsAU}

Public Property myPlaceBets() As Object()
Get
Return _PlaceBets(exch angeId - 1)
End Get
Set(ByVal Value As Object())
_PlaceBets(exch angeId - 1) = Value
End Set
End Property

' a single bet

Private _PlacebetsUK As New BF4_1_rel_13_4. betfair.uk.exch ange.PlaceBets
Private _placebetsAU As New BF4_1_rel_13_4. betfair.au.exch ange.PlaceBets
Private Placebet() = {_PlacebetsUK, _placebetsAU}
Public Property myPlaceBet()
Get
Return Placebet(exchan geId - 1)
End Get
Set(ByVal Value)
Placebet(exchan geId - 1) = Value
End Set
End Property

' a betting request

Private _myPlaceBetsReq UK As New betfair.uk.exch ange.PlaceBetsR eq
Private _myPlaceBetsReq AU As New betfair.au.exch ange.PlaceBetsR eq
Private _PlaceBetsReq() = {_myPlaceBetsRe qUK, _myPlaceBetsReq AU}

Public Property myPlaceBetsReq( )
Get
Return _PlaceBetsReq(e xchangeId - 1)
End Get
Set(ByVal value)
_PlaceBetsReq(e xchangeId - 1) = value
End Set
End Property

Here is the code:

ReDim Preserve myPlaceBets(bet Count)
myPlaceBets(bet Count) = myPlaceBet

myPlaceBets(bet Count).price = myOdds
Here's the result
- myPlaceBets(bet Count).price 1.01 {Double} Object
+ Double 1.01 {Double} Double

the next statement FAILS
myPlaceBets(bet Count).price =
Decimal.Parse(m yPlaceBets(betC ount).price.ToS tring("#0.00"))

Here's the error message
System.FormatEx ception: Input string was not in a correct format.
at Microsoft.Visua lBasic.Compiler Services.Conver sions.ParseDoub le(String
Value, NumberFormatInf o NumberFormat)
at Microsoft.Visua lBasic.Compiler Services.Conver sions.ToInteger (String
Value) 08/03/2007 14:59:45 487
Having continued and entered the bet parameters they can be seen here:
- myPlaceBets {Length=1} Object()
- (0) {BF4_1_rel_13_4 .betfair.uk.exc hange.PlaceBets } Object
- BF4_1_rel_13_4. betfair.uk.exch ange.PlaceBets {BF4_1_rel_13_4 .betfair.uk.exc hange.PlaceBets } BF4_1_rel_13_4. betfair.uk.exch ange.PlaceBets
asianLineId 0 Integer
asianLineIdFiel d 0 Integer
betType L {1} uk.exchange.Bet TypeEnum
betTypeField L {1} uk.exchange.Bet TypeEnum
marketId 20001695 Integer
marketIdField 20001695 Integer
price 1.01 Double
priceField 1.01 Double
selectionId 2002335 Integer
selectionIdFiel d 2002335 Integer
size 2.0 Double
sizeField 2.0 Double

Executing the next statment moving the bet into the request:

myPlaceBetsReq. bets = myPlaceBets

we get the following error:

Conversion from type 'Object()' to type 'PlaceBets()' is not valid.
at Microsoft.Visua lBasic.Compiler Services.Conver sions.ChangeTyp e(Object
Expression, Type TargetType)
at
Microsoft.Visua lBasic.Compiler Services.Overlo adResolution.Pa ssToParameter(O bject Argument, ParameterInfo Parameter, Type ParameterType)
at
Microsoft.Visua lBasic.Compiler Services.NewLat eBinding.Constr uctCallArgument s(Method TargetProcedure , Object[] Arguments, BindingFlags LookupFlags)
at
Microsoft.Visua lBasic.Compiler Services.Symbol s.Container.Inv okeMethod(Metho d
TargetProcedure , Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
at Microsoft.Visua lBasic.Compiler Services.NewLat eBinding.LateSe t(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean
RValueBase, CallType CallType)
at
Microsoft.Visua lBasic.Compiler Services.NewLat eBinding.LateSe tComplex(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean
RValueBase)
at BF4_1_rel_13_4. mainForm.EnterB tn_Click(Object sender, EventArgs e) in
C:\Documents and Settings\victor sperber\Desktop \BF
API5\BFAustrali a\BF4_1_rel_13_ 4\mainform.vb:l ine 5832
Gadya

"Patrice" wrote:
Do UK And AU exposes the same methods ?

See OOP details at :
http://msdn2.microsoft.com/en-us/lib...56(VS.71).aspx (in particular
4.3/4.5 or 4.4).

Basically 4.3 is :
- your classes share come common code. You use an Ancestor class that
implements common behavior. The UK and AU inherits from this common ancestor
their common behavior and can specialize themselves. Using an As Ancestor
array you'll be able to use either UK and AU (as you have the guarantee that
methods exposed by thr Ancestor are also available in UK /AU as they inherit
from Ancestor).

If they have nothing related but still exposes the same classe methodfs you
could see 4.4 that sjust allows to guarantee that they both exposes the same
methods. You can then use an As IMyInterface array.

This is the a very qucik overview. Your best bet is to read on a tutorial
about OOP.

--
Patrice

"gadya" <ga***@discussi ons.microsoft.c oma écrit dans le message de news:
08************* *************** **...icrosof t.com...
I use one of 2 arrays dependent on the country.

Rather than say:
if exchangeID = 1 then
dim myPlaceBets() as As UK.exchange.Pla ceBets
many statements
myPlaceBetsReq. bets = myPlaceBets
else
dim myPlaceBets() As AU.exchange.Pla ceBets
many statements
myPlaceBetsReq. bets = myPlaceBets
end if

I want to say is something like this:

Public Property myPlaceBets() As
BF4_1_rel_13_4. betfair.UK.exch ange.PlaceBets OR as
BF4_1_rel_13_4. betfair.AU.exch ange.PlaceBets

Not being able to do this I said

Public Property myPlaceBets() As Object

Defining the property as Object, while the correct array is returned, it
fails in use with the message:

Conversion from type 'Object()' to type 'PlaceBets()' is not valid. Here's
the Property.

Private _myPlaceBetsUK(-1) As UK.exchange.Pla ceBets
Private _myPlaceBetsAU(-1) As AU.exchange.Pla ceBets
Private _PlaceBets() = {_myPlaceBetsUK , _myPlaceBetsAU}

Public Property myPlaceBets() As Object
Get
Return _PlaceBets(exch angeId - 1)
End Get
Set(ByVal Value As Object)
_PlaceBets(exch angeId - 1) = Value
End Set
End Property

Any help would be appreciated.

Gadya


Mar 8 '07 #3

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

Similar topics

7
3059
by: Harry Pehkonen | last post by:
I have been defining new class methods when I'm trying to simplify some code. But I'm thinking I should just define functions within that method because they aren't useful from the outside anyway. Example: Before: class Mess(object): def complicated(self, count):
0
2314
by: Dotnetified | last post by:
Reposting after about 2 weeks of no response ... thanks if you can help... ---------------------------------------------------------------------------- -------------- To anyone who thinks they know it all: ;) We recently upgraded our MSDN Version of VS.NET 2002 to VS.NET 2003... Things are all working well, except we've run across a new bug or issue since our adopting of the new package.
12
3222
by: Matt Garman | last post by:
I'd like to create a "custom output facility". In other words, I want an object whose use is similar to std::cout/std::cerr, but offers more flexibility. Instead of simply writing the parameter to stdout/stderr, I'd like it to write to stdout, to a file, and/or call a logging function. So my output function might look something like this: OutputFacility& OutputFacility::put(const std::string& s) { cout << s; // print to stdout
19
1958
by: mehdi.louizi | last post by:
Hello, I'm beginning to create a web site but I'm facing a big problem for which I didn't find any solution!! I'm using the 1024*768 screen resolution, and when I change it to 800*600 the page is visible but with the scroll bars. So the design is no longer the same.. Same thing if I work on a 800*600 resolution, the page is too ugly to bee seen.. I don't want to work with frames. Concerning the creation of tables with fixed width (100 %),...
10
6701
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
16
4355
by: Howard Jess | last post by:
All -- I'm trying to solve a problem for which I think the solution will be to *cheat*; but I don't mind doing so for this case. The background is: Given an object constructor, and an instance SampleObj = function() { this.prop = 1; }
26
2552
by: Cliff Williams | last post by:
Can someone explain the pros/cons of these different ways of creating a class? // 1 function myclass() { this.foo1 = function() {...} } // 2a
0
1065
by: DFS | last post by:
Probably someone else has done this, but I figured out a flexible way to use the Leban's calendar, such that you don't have to write code in the DblClick event each time you want to use the control. This method works with one date field at a time, ie a start date with no end date. If you want to use the control to fill in a start/end range, you need to write code in the DblClick event of the start date and specify the field names. ...
0
836
by: =?Utf-8?B?Z2FkeWE=?= | last post by:
I use one of 2 arrays dependent on the country. Rather than say: if exchangeID = 1 then dim myPlaceBets() as As UK.exchange.PlaceBets many statements myPlaceBetsReq.bets = myPlaceBets else dim myPlaceBets() As AU.exchange.PlaceBets many statements
0
9833
marktang
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...
0
10867
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, 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...
0
10562
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 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...
0
10263
tracyyun
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...
1
7803
isladogs
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...
0
6989
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();...
0
5666
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5842
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3122
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.