[RESOLVED] ArrayTypeMismatchException error
I get an ArrayTypeMismatchException error with this code:
Private Sub btnCellsRand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCellsRand.Click
Code:
If IsNumeric(tbxRandomCells.Text) = False Then
MessageBox.Show("You must enter a number.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return
End If
Dim MyArraycells(Me.lbxCellsArray.Items.Count - 1) As String
Me.lbxCellsArray.Items.CopyTo(MyArraycells, 0)
Dim myListcells As New List(Of String)
myListcells.AddRange(MyArraycells)
Dim rnd As New System.Random
Dim randomnumber As Integer = 0
Me.tbxRandomCells.Text = ""
Dim count As Integer = 0
If Integer.TryParse(tbxRandomCells.Text, count) Then
If Int32.Parse(tbxRandomCells.Text) <= Int32.Parse(lblTotalCells.Text) Then
Do While count <> 0
randomnumber = rnd.Next(0, myListcells.Count)
tbxRandomCells.Text &= myListcells(randomnumber) & vbCrLf & ""
myListcells.RemoveAt(randomnumber)
count -= 1
Loop
Else
MessageBox.Show("Your random number is higher than" & vbCrLf & " the total number of cells.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End If
any ideas as to why? Only thing I can think of is that the listbox is data bound to an ms access DB. Would that cause the error?
Re: ArrayTypeMismatchException error
never mind I figured it out