compre the wordListBox.Item

Herbie000

Member
Joined
Dec 15, 2007
Messages
5
Programming Experience
Beginner
I cat figure out how to get this to work. I would like to be able to compre the wordListBox.Item Wild to what the user clicks and wild should match any other wordListBox.Item. I am just not getting it please help.

VB.NET:
    Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' fills the list box with 8 pairs of matching words, 
        ' then calls a procedure to shuffle the words

        wordListBox.Items.Add("Refrigerator")
        wordListBox.Items.Add("Range")
        wordListBox.Items.Add("Television")
        wordListBox.Items.Add("Computer")
  -----<Snip>----

    Private Sub GetSecondItem(ByVal strItem As String)       
 Dim i As Integer
        For i = 0 To wordListBox.Items.Count - 1

            If strItem = wordListBox.Items(i).ToString Then
                Select Case i
                    Case 0
                        Label1.Text = strItem
                        Label1.BackColor = Color.Red
                        Label1.Enabled = False
                    Case 1
                        Label2.Text = strItem
                        Label2.BackColor = Color.Red
                        Label2.Enabled = False
  -----<Snip>----

                    Case 15
                        Label16.Text = strItem
                        Label16.BackColor = Color.Red
                        Label16.Enabled = False
                End Select

            End If
        Next i
    End Sub
 
is wild a string? ie "wild"
or a wildcard string?

VB.NET:
If strItem = wordListBox.Items(i).ToString Then
is case sensitive
 
I am sorry I cut of part of the code the wild card is

wordListBox.Items.Add("Wild")


is it as simple as this?

If strItem = wordListBox.Items(Wild).ToString Then
 
Here is an over all of what I would like the program to do. This is a matching game. When the user clicks a wild card for the first card or the second card the program needs to be able to search the wordListBox.Items for the other matching word that is the non wild card and then "turn" that card over or it will never have a match. I can attach the entire file if it would help.
 
I think I have it figured out but when the wild card is clicked the game stops it will not let me click any other cards. I think it's something in this poriton of code when I debug it looks as if it just stops at end sub..The code in red is what I added before that it would not stop when the wild clicked...but then it wouldn't search for the other non wild word.

VB.NET:
If firstLabel.Text = secondLabel.Text Then
                firstLabel.Enabled = False
                secondLabel.Enabled = False
                matchTimer.Enabled = True
                firstLabel.BackColor = Color.Red
                secondLabel.BackColor = Color.Red

[COLOR="Red"]            ElseIf firstLabel.Text = "Wild" Then
                GetSecondItem(firstLabel.Text)
                firstLabel.BackColor = Color.Red
                secondLabel.BackColor = Color.Red

            ElseIf secondLabel.Text = "Wild" Then
                GetSecondItem(firstLabel.Text)
                firstLabel.BackColor = Color.Red
                secondLabel.BackColor = Color.Red[/COLOR]

            Else
                noMatchTimer.Enabled = True
            End If

            'reset the selection counter
            selectionCounter = 0

        End If
    End Sub
 
Last edited:
Back
Top