Results 1 to 6 of 6

Thread: VB League Table Picture Box Text Arrangment.. :)

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    7

    Exclamation VB League Table Picture Box Text Arrangment.. :)

    Hello, this is my first post in this form

    I have a question i am not sure can be answered. I am very new to visual basic and have just started studying it in A Level Computing (UK). Basically our teachers a bit of a nob and dont help us because he cant...

    Anyway.. I am currently building a program for my final project. Its a league table ( the usual 3 points for a win 1 for a draw etc ) like football (soccer) etc.

    The table has a text file where the program picks up the team names etc and has them printed out on a picture box. I then go to my fixtures section of the program and process a fixture which updates the text file and the picture box accoring to who won (will give winners 3 points etc).

    I then have a table updated perfectly everything going right on the picture box but i do not know if i can arrange the points by highest (have the team with the most points at the top lowest at the bottom). In the text file the teams are lined up like this...

    Arsenal
    0
    0
    0
    0
    0
    Chelsea
    1
    0
    1
    0
    1
    Man Utd
    0
    0
    0
    0
    0
    Liverpool
    3
    0
    3
    0
    3
    Tottenham
    3
    0
    3
    0
    3
    Wigan
    0
    0
    0
    0
    0
    Bolton
    1
    0
    1
    0
    1
    Man City
    0
    0
    0
    0
    0
    Blackburn
    0
    0
    0
    0
    0
    West Ham
    0
    0
    0
    0
    0
    Charlton
    0
    0
    0
    0
    0
    Fulham
    0
    0
    0
    0
    0
    Newcastle
    0
    0
    0
    0
    0
    Everton
    0
    0
    0
    0
    0
    Aston Villa
    0
    0
    0
    0
    0
    West Brom
    0
    0
    0
    0
    0
    Middlesboro
    0
    0
    0
    0
    0
    Portsmouth
    0
    0
    0
    0
    0
    Birmingham
    0
    0
    0
    0
    0
    Sunderland
    0
    0
    0
    0
    0

    As you can see some have been updated..

    the first zero repesents Games Played
    the second Games Won
    third Games Drawn
    fourth Games Lost
    fifth Points...

    Its the fifth zero that i need arranged..

    This is what this looks like printed on the picturebox...

    CLICK HERE

    Im sorry if this is hard to understand but i am very new as im sure many people are on here.

    Thanks Alot for anytime you spend on trying to answer this question.

    Moka
    Last edited by Moka; Apr 14th, 2006 at 06:57 PM.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: VB League Table Picture Box Text Arrangment.. :)

    Welcome to VB Forums!

    I don't have the time time now to actually do the code, but you could create a user defined type like this

    VB Code:
    1. Option Explicit
    2. Private Type League
    3.     Team As String
    4.     Played As Integer
    5.     Won As Integer
    6.     Drawn As Integer
    7.     Lost As Integer
    8.     Points As Integer
    9. End Type

    And then create an array like this to hold the data until you want to print it.

    Dim LeageTable(18) As League

    And once you have all the data you could do a bubble sort (which you can Search for examples of) and then print from the sorted array.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    7

    Re: VB League Table Picture Box Text Arrangment.. :)

    I thought the best way would be to upload my work so someone could maybe download and have a look to see if they know how i would arrange the League Table via Points.

    Thanks for anyone who takes the time in helping me out here...

    CLICK HERE TO DOWNLOAD TABLE

  4. #4

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    7

    Re: VB League Table Picture Box Text Arrangment.. :)

    no sorry i didnt, i have never done nethink like this before and i have no idea what to do with what you told me. If you have time could you explain it more?

    i already have an array. can i arrange information in a text file before it gets printed onto a picturebox?

    Thanks
    Moka

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: VB League Table Picture Box Text Arrangment.. :)

    VB Code:
    1. Option Explicit
    2. Private Type League
    3.     Team As String
    4.     Played As Integer
    5.     Won As Integer
    6.     Drawn As Integer
    7.     Lost As Integer
    8.     Points As Integer
    9. End Type
    10.  
    11. Private Sub Form_Load() ' You wouldn't do this in Form_Load
    12.  
    13.     Dim LeageTable(18) As League
    14.     Dim Temp As League
    15.     Dim lngIndex As Long
    16.     Dim bSwapped As Boolean
    17.    
    18.     'Add some test data (I know the values don't make sense)
    19.     LeageTable(0).Team = "Arsenal"
    20.     LeageTable(0).Played = 0
    21.     LeageTable(0).Won = 0
    22.     LeageTable(0).Lost = 0
    23.     LeageTable(0).Drawn = 0
    24.     LeageTable(0).Points = 3
    25.     LeageTable(1).Team = "Liverpool"
    26.     LeageTable(1).Played = 0
    27.     LeageTable(1).Won = 0
    28.     LeageTable(1).Lost = 0
    29.     LeageTable(1).Drawn = 0
    30.     LeageTable(1).Points = 5
    31.     LeageTable(2).Team = "Tottenham"
    32.     LeageTable(2).Played = 0
    33.     LeageTable(2).Won = 0
    34.     LeageTable(2).Lost = 0
    35.     LeageTable(2).Drawn = 0
    36.     LeageTable(2).Points = 2
    37.     LeageTable(3).Team = "Man Utd"
    38.     LeageTable(3).Played = 0
    39.     LeageTable(3).Won = 0
    40.     LeageTable(3).Lost = 0
    41.     LeageTable(3).Drawn = 0
    42.     LeageTable(3).Points = 1
    43.    
    44.     'sort the data
    45.     bSwapped = True
    46.     Do Until bSwapped = False
    47.         bSwapped = False
    48.         For lngIndex = 0 To 2 ' you would use 17
    49.             If LeageTable(lngIndex).Points <= LeageTable(lngIndex + 1).Points Then
    50.                 ' store the lower value data to be replaced
    51.                 Temp.Drawn = LeageTable(lngIndex).Drawn
    52.                 Temp.Lost = LeageTable(lngIndex).Lost
    53.                 Temp.Played = LeageTable(lngIndex).Played
    54.                 Temp.Points = LeageTable(lngIndex).Points
    55.                 Temp.Team = LeageTable(lngIndex).Team
    56.                 Temp.Won = LeageTable(lngIndex).Won
    57.                 ' move the higher values up one in the array
    58.                 LeageTable(lngIndex).Drawn = LeageTable(lngIndex + 1).Drawn
    59.                 LeageTable(lngIndex).Lost = LeageTable(lngIndex + 1).Lost
    60.                 LeageTable(lngIndex).Played = LeageTable(lngIndex + 1).Played
    61.                 LeageTable(lngIndex).Points = LeageTable(lngIndex + 1).Points
    62.                 LeageTable(lngIndex).Team = LeageTable(lngIndex + 1).Team
    63.                 LeageTable(lngIndex).Won = LeageTable(lngIndex + 1).Won
    64.                 ' replace the old higher value data with the saved lower values
    65.                 LeageTable(lngIndex + 1).Drawn = Temp.Drawn
    66.                 LeageTable(lngIndex + 1).Lost = Temp.Lost
    67.                 LeageTable(lngIndex + 1).Played = Temp.Played
    68.                 LeageTable(lngIndex + 1).Points = Temp.Points
    69.                 LeageTable(lngIndex + 1).Team = Temp.Team
    70.                 LeageTable(lngIndex + 1).Won = Temp.Won
    71.                 bSwapped = True
    72.             End If
    73.         Next
    74.     Loop
    75.    
    76.     ' The array is now sorted with the highest point teams at the top and you
    77.     ' can print that data to the picture.
    78. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width