Results 1 to 2 of 2

Thread: Dynamic Listboxes?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    Gainesville, FL
    Posts
    131
    Hello again! I am writing a function that will search one of two listboxes depending on a different variable.

    This is how I'm attempting to do it:


    Code:
    Public Function GetPoints(TheirName As String)
    Dim CurrentScore As Integer
    Dim theirpos As Integer
    Dim TheList As ListBox
    Dim team as integer
    
    team = 1
    
    'IGNORE EVERYTHING FROM HERE
    If dummy.TeamGame.value = 1 Then
        If theirpos = -1 Then
            theirpos = FindPlayer(TheirName, frmPlayers.playerlist2)
            team = 2
        End If
    End If
    'TO HERE!
    
    'HERE IS MY PROBLEM:
    If team = 1 Then TheList = frmPlayers.playerlist1
    If team = 2 Then TheList = frmPlayers.playerlist2
    
    
    theirpos = FindPlayer(TheirName, TheList)
    thelistname = TheList.List(theirpos)
    seppos = InStr(1, thelistname, "|", vbTextCompare)
    CurrentScore = Val(Mid$(TheirName, seppos + 2))
    GetPoints = CurrentScore
    
    End Function
    At the part where I have
    Code:
    If team = 1 Then TheList = frmPlayers.playerlist1
    If team = 2 Then TheList = frmPlayers.playerlist2
    I get the following error:
    Run-Time error 91:
    Object variable or With block variable not set.


    Any suggestions?

  2. #2
    Member
    Join Date
    Apr 1999
    Posts
    56
    I think you need to do this:
    If team = 1 Then Set TheList = frmPlayers.playerlist1
    If team = 2 Then Set TheList = frmPlayers.playerlist2

    Put Set in front of TheList.

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