Using a matrix to produce a result

S

Scott

I have generated a form that inserts travel information and I need to
manipulate that info. All the info is now stored in variable and i need to
generate prices... Its a little complicated cos there is not a relative
price structure. Ill try and explain whets happening...

variable1 - either european or worldwide
variable2 - 1_person, 2_people or a family
variable3 - standard_baggage or include_luggage
variable4 - length of trip (either 1-5, 6-10, 11-17, 18-24, 25-31 & 32-38
days)

the first 3 variables are radio buttons and the last one is a text box and I
have all the info in variables. You must remember that there are many many
different instances for the prices and I need to know how to get this
correctly working???

Thanks
Scott
 
C

Cor Ligthert

Scott,

Probably you get more and better answers when you answers the replies you
get from people (like me) to make your problem more understandable what you
are up to.

(I asked you by instance if this was for a PC or for a PDA) because you was
talking about a calculator.

And when it is the first the second question would be than if it was for a
winform or a webform.

Just my thought,

Cor
 
P

Phill. W

Scott said:
I have generated a form that inserts travel information and I need to
manipulate that info. All the info is now stored in variable and i need to
generate prices... Its a little complicated cos there is not a relative
price structure. Ill try and explain whets happening...

variable1 - either european or worldwide
variable2 - 1_person, 2_people or a family
variable3 - standard_baggage or include_luggage
variable4 - length of trip (either 1-5, 6-10, 11-17, 18-24, 25-31 & 32-38
days)

the first 3 variables are radio buttons and the last one is a text box and I
have all the info in variables.

A suggestion -

European or Worldwide - 2 possible cases
Standard or Include luggage - 2 possible cases
1, 2, or family - 3 possible cases

That gives you twelve (2 * 2 * 3) possibilities of these three values.
With a little arithmetical jiggery-pokery, you could merge these into
a single value, as in

0 = European, 8 = WorldWide

0 = Standard (Luggage), 4 = Include

0 = 1 person
1 = 2 persons
2 = family

Now, you simply add up the selected values to get a single result
for any combinatio of the three fields, as in

0 = European, Standard, 1_Person
1 = European, Standard, 2_Person
2 = European, Standard, Family
4 = European, Include, 1_Person
5 = European, Include, 2_Person
6 = European, Include, Family
8 = WorldWide, Standard, 1_Person
9 = WorldWide, Standard, 2_Person
10 = WorldWide, Standard, Family
12 = WorldWide, Include, 1_Person
13 = WorldWide, Include, 2_Person
14 = WorldWide, Include, Family

Now, if you create "bands" for your durations as well,

0 = 1-5
1 = 6-10
2 = 11-17
3 = 18-24
etc.

You can create a simple matrix linking the two (OK, it'll have a few
holes in it.)

Alternatively, you /might/ want to consider dropping all of this data
into a Database of some sort - this is /just/ what they're good at!

HTH,
Phill W.
 
S

Scott

Yeah you know what I'm talking about! What kind of coding would be needed
for this? I can't seem to think laterally on this one. but you have given
me a few ideas.. Thats progress...

Scott
 
P

Phill. W

Scott,

Because you're playing with a mixture of Controls (CheckBoxes,
TextBoxes, etc.) you're probably going to need your own function
to do the "adding up", so you can call it from each Event Handler,
something like:

Private Function CalcTravelType() as Integer
Dim iRC as Integer = 0

'If Me.Radio1Person.Checked Then
' iRC += 0
If Me.Radio2Person.Checked Then
iRC += 1
ElseIf Me.RadioFamily.Checked Then
iRC += 2
End If

'If Me.RadioStdLuggage.Checked Then
' iRC += 0
If Me.RadioIncLuggage.Checked Then
iRC += 4
End If

'If Me.RadioEuropean.Checked Then
' iRC += 0
If Me.RadioWorldWide.Checked Then
iRC += 8
End If

Return iRC
End Function

Private Sub RadioPersons_CheckChanged( _
ByVal sender as Object _
, ByVal e as ... _
)

DoSomethingWith( CalcTravelType() )

End Sub

Private Sub TextDuration_Validated( _
ByVal sender as Object _
, ByVal e as ... _
)

DoSomethingWith( CalcTravelType() )

End Sub

HTH,
Phill W.
 
A

Andy O'Neill

Scott said:
I have generated a form that inserts travel information and I need to
manipulate that info. All the info is now stored in variable and i need to
generate prices... Its a little complicated cos there is not a relative
price structure. Ill try and explain whets happening...

variable1 - either european or worldwide
variable2 - 1_person, 2_people or a family
variable3 - standard_baggage or include_luggage
variable4 - length of trip (either 1-5, 6-10, 11-17, 18-24, 25-31 & 32-38
days)

the first 3 variables are radio buttons and the last one is a text box and
I have all the info in variables. You must remember that there are many
many different instances for the prices and I need to know how to get this
correctly working???

Thanks
Scott
If I was working on this, my data would be in a dataset and this'd be
written to a table.
The controls involved wouldn't matter so much.
I'd also have everything else in tables...
The calculation would be a case of (destinationCost + luggage + etc) per
person
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top