我正在使用VISUAL STUDIO 2010进行电子抽奖项目。我在sql数据库中有一个名称列表,并将其显示在列表视图中,以及有关应显示哪些名称的某些条件。现在,我要从列表视图中随机选择名称。我正在尝试从listview转换此项目并将其转换为字符串数组。我也有计时器,当它在enable=true
时,应该在标签上显示这些字符串数组。
当代码为enable=false
时。它应该停止并显示一个特定的名称。我的所有代码都正常工作,但在此特定代码行中我得到InvalidCastException
是unhandled
ReDim strng(Name_ListView.Items.Count - 1)
Name_ListView.Items.CopyTo(strng, 0)
Dim strng() As String
Private Sub Frm_Raffle_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ReDim strng(Name_ListView.Items.Count - 1)
Name_ListView.Items.CopyTo(strng, 0)
End Sub
Public Sub myTimer_Tick(sender As System.Object, e As System.EventArgs) Handles myTimer.Tick
Dim index As Integer = rnd.Next(Name_ListView.Items.Count)
mylblResult.Text = strng(index)
End Sub