Results 1 to 1 of 1

Thread: vb desperate help!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    22

    vb desperate help!!

    can you help me with the second part of the app..How do you write an application to navigate the files created..in part a..which is the entire code below..It will display all data for one player at a time. There is a menu, to view first, next , previous, last, record..Also please include a search...to find..all records..according to team id..Arrays are not allowed in this app..Please help me..I really hope you can help me out with this..Also please include a find/search next option to find the next option where the target string can be found in the players name and the find next which will find the next matching record. note: all data remains on disk except the current record. Please help me!

    this is the code...for the module:

    Option Explicit

    Type TeamRec
    Team As String * 30
    Division As String * 20
    Conference As String * 20
    End Type

    Type PlayerRecordOne
    IDNumber As Integer
    Jersey As Integer
    PlayerInfo1 As String * 20
    Position As String * 2
    PHeight As String * 5
    PWeight As Integer
    Birthdate As String * 10
    YearsInLeague As Integer
    BirthCity As String * 20
    BirthCountry As String * 20
    Team As String * 30
    End Type

    Type PlayerRecordTwo
    Name As String * 25
    Jersey As Integer
    Position As String * 2
    PHeight As String * 5
    PWeight As Integer
    Birthdate As String * 10
    BirthCity As String * 20
    BirthCountry As String * 20
    TeamID As Integer
    End Type









    'Initialize the variables.

    Sub Initialize(Team() As TeamRec, PlayerNumber As Integer, PlayerData() As PlayerRecordTwo, PlayerInfo1() As PlayerRecordOne, TeamData() As TeamRec)
    Dim k As Integer
    Dim MAX As Integer

    For k = 1 To MAX
    With PlayerInfo1(k)
    .IDNumber = 0
    .Jersey = 0
    .PlayerInfo1 = ""
    .Position = ""
    .PHeight = ""
    .PWeight = 0
    .Birthdate = ""
    .YearsInLeague = 0
    .BirthCity = ""
    .BirthCountry = ""
    .Team = ""
    End With

    With PlayerData(k)
    .Name = ""
    .Jersey = 0
    .Position = ""
    .PHeight = ""
    .PWeight = 0
    .Birthdate = ""
    .BirthCity = ""
    .BirthCountry = ""
    .TeamID = 0
    End With

    With Team(k)
    .Team = ""
    .Division = ""
    .Conference = ""
    End With

    With TeamData(k)
    .Team = ""
    .Division = ""
    .Conference = ""
    End With

    Next k

    PlayerNumber = 0
    End Sub

    'Read file "Nhl2000.dat" into two arrays - "Player()" and "Team()".

    Function ReadFile(Team() As TeamRec, PlayerInfo1() As PlayerRecordOne) As Integer


    Dim Temp As Integer
    Dim MAX As Integer
    Dim k As Integer
    Dim St As String
    Dim msg As String
    Dim answer As Integer
    Dim ErrorFound As Boolean
    Dim dtype As Integer

    On Error GoTo ReadFileError



    Temp = 0
    k = 0

    Open "A:\Nhl2000.dat" For Input As #1
    Do While Not EOF(1)
    k = k + 1

    With PlayerInfo1(k)
    Input #1, .IDNumber
    Input #1, .Jersey
    Input #1, .PlayerInfo1
    Input #1, .Position
    Input #1, .PHeight
    Input #1, .PWeight
    Input #1, .Birthdate
    Input #1, .YearsInLeague
    Input #1, .BirthCity
    Input #1, .BirthCountry
    Input #1, .Team
    End With

    With Team(k)
    .Team = PlayerInfo1(k).Team
    Input #1, .Division
    Input #1, .Conference
    End With

    Loop
    Close #1

    Temp = k
    ReadFile = Temp

    Exit Function

    ReadFileError:
    ErrorFound = True
    msg = Error$(Err) & "!"
    Select Case Err
    Case 71
    msg = msg & " Check disk and drive."
    dtype = vbAbortRetryIgnore + vbCritical
    answer = MsgBox(msg, dtype, "Error")
    If answer = vbRetry Then
    ErrorFound = False
    Resume
    End If
    Case Else
    msg = "Error # " & Err & ":" & msg
    MsgBox msg, vbCritical, "Error"
    End Select
    Exit Function


    End Function

    'Find the number of unique team and read array "Team()" into different array "TeamData()".

    Function UniqueTeam(Team() As TeamRec, TeamData() As TeamRec) As Integer
    Dim k As Integer
    Dim i As Integer
    Dim j As Integer
    Dim Temp As Boolean
    Dim N As Integer

    i = 1
    TeamData(i) = Team(1)
    j = i

    For k = 2 To N
    Temp = True

    Do
    If Team(k).Team <> TeamData(j).Team Then
    Temp = False
    Else
    Temp = True
    End If
    j = j - 1
    Loop Until j = 0 Or Temp = True

    If Temp = False Then
    i = i + 1
    TeamData(i) = Team(k)
    j = i
    Else
    j = i
    End If

    Next k

    UniqueTeam = i
    End Function

    'Read array "Player()" into array "PlayerData".

    Sub PlayerDataFile1(PlayerData() As PlayerRecordTwo, PlayerInfo1() As PlayerRecordOne, PlayerNumber As Integer, TeamData() As TeamRec, NumTeam As Integer)
    Dim k As Integer
    Dim i As Integer


    For k = 1 To PlayerNumber

    With PlayerData(k)
    .Name = PlayerInfo1(k).PlayerInfo1
    .Jersey = PlayerInfo1(k).Jersey
    .Position = PlayerInfo1(k).Position
    .PHeight = PlayerInfo1(k).PHeight
    .PWeight = PlayerInfo1(k).PWeight
    .Birthdate = PlayerInfo1(k).Birthdate
    .BirthCity = PlayerInfo1(k).BirthCity
    .BirthCountry = PlayerInfo1(k).BirthCountry
    For i = 1 To NumTeam
    If PlayerInfo1(k).Team = TeamData(i).Team Then
    .TeamID = i
    End If
    Next i
    End With
    Next k

    End Sub

    'Use array "TeamData()" to create "TeamFile.Rec".

    Sub TeamDataFile(TeamData() As TeamRec)

    Dim Length As Integer
    Dim k As Integer
    Dim N As Integer


    Kill ("A:\TeamFile.Rec")
    Length = Len(TeamData(1))

    Open "A:\TeamFile.Rec" For Random As #1 Len = Length
    For k = 1 To N
    Put #1, k, TeamData(k)
    Next k
    Close #1

    End Sub

    'Use array "PlayerData()" to create "PlayerFile.Rec".

    Sub PlayerDataFile2(PlayerData() As PlayerRecordTwo, PlayerNumber As Integer)


    Dim Length As Integer, k As Integer
    Dim j As Integer



    Kill ("A:\PlayerFile.Rec")

    Length = Len(PlayerData(1))
    Attached Files Attached Files

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