请教啊!VB :双击listBox2中数据进行计数投票(在listBox3中显示并显示最多的那个) 10
InvalidArgument=“0”的值对于“index”无效。参数名:indexPublicClassForm1PrivateSubForm1_Load(ByVals...
InvalidArgument=“0”的值对于“index”无效。
参数名: index
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox3.Visible = False
ListBox1.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox3.Visible = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As --向右按钮System.EventArgs) Handles Button2.Click
ListBox2.Items.Add(ListBox1.SelectedItem.ToString)
ListBox1.Items.Remove(ListBox1.SelectedItem.ToString)
ListBox1.SelectedIndex = 0
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As --向左按钮System.EventArgs) Handles Button3.Click
If ListBox2.SelectedIndex >= 0 Then
ListBox1.Items.Add(ListBox2.SelectedItem.ToString)
ListBox2.Items.Remove(ListBox2.SelectedItem.ToString)
Else
MessageBox.Show("请选择一个后选人", "错误")
End If
End Sub
Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As ---双击System.EventArgs) Handles ListBox2.DoubleClick
If ListBox2.SelectedItems.Count > 0 Then
ListBox3.Items(ListBox2.SelectedIndex) = 1
End If
End Sub
End Class 展开
参数名: index
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox3.Visible = False
ListBox1.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox3.Visible = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As --向右按钮System.EventArgs) Handles Button2.Click
ListBox2.Items.Add(ListBox1.SelectedItem.ToString)
ListBox1.Items.Remove(ListBox1.SelectedItem.ToString)
ListBox1.SelectedIndex = 0
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As --向左按钮System.EventArgs) Handles Button3.Click
If ListBox2.SelectedIndex >= 0 Then
ListBox1.Items.Add(ListBox2.SelectedItem.ToString)
ListBox2.Items.Remove(ListBox2.SelectedItem.ToString)
Else
MessageBox.Show("请选择一个后选人", "错误")
End If
End Sub
Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As ---双击System.EventArgs) Handles ListBox2.DoubleClick
If ListBox2.SelectedItems.Count > 0 Then
ListBox3.Items(ListBox2.SelectedIndex) = 1
End If
End Sub
End Class 展开
1个回答
展开全部
没理解你这程序在listbox3里的处理过程是什么?
更多追问追答
追问
题目要求:通过双击ListBox2中的项(投票),在ListBox3中显示投票数。
比如说ListBox2中有一个后选人叫A,双击这个项A,A对应的票数加1(这个票在ListBox3中对应的位置显示),然后把票数最多的那个人也在ListBox3中显示。
至于我这个呢:意思是当所有人投票结束后,通过点击计票按钮显示所有后选人的票数
谢谢啊
追答
使用listbox3.item(ListBox2.SelectedIndex).tag=+1来存放和计算票数。还有你这程序是联网计票?
至于票数最多的人,可以使用二变量比较来。但这个方法有点笨了,直接使用items的排序功能好了,方便又迅速。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询