Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Looking for suggestions


Reply
 
Thread Tools Display Modes
  #1  
Old 07-29-2010, 05:28 PM
paskov paskov is offline
Newcomer
 
Join Date: Jul 2010
Posts: 2
Default Looking for suggestions

Any help is appreciated. I was asked to write code for the following situation:
a) a variable number of people, up to 24 max
2) each participating in 10 different activities
3) 23 scoring days
Each day I will receive as input person name and 10 numbers of his/her daily progress in each of the 10 categories. For example, "Tom, 1,3,2.7, -0.2, etc.

I must add daily and provide not the total of each category but relative standings. And that's where I am left wandering how to do it. Let's say there are 24 people. If Tom is last in category A, he gets 1 point, if he is the top performer he gets 24 points. If he is anywhere in between, he gets assigned a score that is in between 1 and 24.
How do I compare running totals in VB?
Sure, I can write a bunch of If Then Else, but there must be a better way. Clearly, I am not good enough to know how.
Thank you
Reply With Quote
  #2  
Old 07-29-2010, 06:18 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 459
Default Select Case

Select Case would be better than a ton of "if then". But let's say we have:

Day 1

Tom 1, 2, 3, 1, 5, 4, 2, 5, 8, 6 = 10 activity times
Larry 3, 2, 1, 1, 5, 3, 4, 5, 6, 2 = 10 activity times

Is Category A, first activity? Or 24 people?

So scoring is 1 to 24? Per activity?

What would they get as a score? And if they tie?

I could make a better suggestion if I see a scoring chart for several people. Seems like what you need is an array of the times, and give them points individually.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #3  
Old 07-29-2010, 06:57 PM
paskov paskov is offline
Newcomer
 
Join Date: Jul 2010
Posts: 2
Default To ZaCkOX

First, thank you very much for replying.
Let me give you a real example. I think that it may help. Let's use 4 people, for sake of space. However, since I am told the the number of people could be between 3 and 24, 4 is a real case.
Let's say use a single category at the moment. Whatever works for one, will work for many.
Example: on day 1 we have:
Tom 10.3
Larry 7.1
Joe -0.3
Mary 6
That means that on day one we have a standing of:
Tom 4
Larry 3
Joe 1
Mary 2
That is, lowest person gets 1 point, the next gets 2 and so on. If we had 24 people, the top person would get 24 points.
Standing is what I was asked to display.
Let's continue. On day 2 we get:
Daily score total of 2 days overall standings
Tom 2.1 12.4 3
Larry 11.3 18.4 4
Joe 11.7 11.4 1.5
Mary 5.4 11.4 1.5
Basically, I need to programatically sort. Is there an algorithm for it that you know of? So simple in Excel, but how to do it by hand? I see only one way to do it: to create a SQL table, insert values, sort and then display. But I could be wrong. I was hoping to avoid using a database.
Reply With Quote
  #4  
Old 07-30-2010, 04:34 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 459
Default Heres how I would start...

This is the way I would start, but you could do this so many ways, anyway refer here about how to sort your numbers:

http://en.wikipedia.org/wiki/Sorting_algorithm

Code:
Option Explicit 'Declare Type Private Type competitors astrCompetitors(1 To 4) As String dblTime(1 To 4) As Double End Type 'Assign Private udtCompetitors As competitors 'Declare Points Private dblPoints(1 To 4) As Double 'Points Awarded Private Sub Form_Load() 'Setup The Arrays With udtCompetitors 'Competitor Names .astrCompetitors(1) = "Tom" .astrCompetitors(2) = "Larry" .astrCompetitors(3) = "Joe" .astrCompetitors(4) = "Mary" 'Times .dblTime(1) = 10.3 .dblTime(2) = 7.1 .dblTime(3) = -0.3 .dblTime(4) = 6 End With 'Declare Dim i As Integer Dim n As Integer Dim dblLowestTime As Double End Sub

You can also write your excel file with the names and scores then write the program to take the data in, might be better that way.

If your still lost how to go from here, just ask for more help :P

Here's a pretty good example I made for how to create a MS Acess mdb file, and acess the database.

http://www.zacharystafford.net/Downloads/MSAcess.zip

But you could do this without it.
__________________
ZaCkO ... Who is your attitude?

Last edited by ZaCkOX; 07-30-2010 at 05:16 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:

Powered by liquidweb