Results 1 to 2 of 2

Thread: [RESOLVED] ArrayTypeMismatchException error

  1. #1

    Thread Starter
    Lively Member irishlad's Avatar
    Join Date
    Oct 2006
    Location
    Arizona
    Posts
    108

    Resolved [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?

  2. #2

    Thread Starter
    Lively Member irishlad's Avatar
    Join Date
    Oct 2006
    Location
    Arizona
    Posts
    108

    Re: ArrayTypeMismatchException error

    never mind I figured it out

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