vb2012列表框ListBox与 复选列表框CheckedListBox问题如何在弹出form2显示
建一个form1,一个ListBox1,一个CheckedListBox1,一个Button1。建一个form2,一个TextBox1。我想要的结果是列表框选择了AAAA后的Aaaa,然后弹出提示“这是Aaaa的结果”,但弹出的都是Caaa的结果这是怎么回事?你能帮我修改一下行吗?
我设计的语句如下:
1、双击form1空白处把一下代码复制粘贴
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("AAAA")
ListBox1.Items.Add("BBBB")
ListBox1.Items.Add("CCCC")
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.Click
CheckedListBox1.Items.Clear()
Select Case ListBox1.SelectedIndex
Case 0
CheckedListBox1.Items.Add("Aaaa")
CheckedListBox1.Items.Add("Abbb")
CheckedListBox1.Items.Add("Accc")
CheckedListBox1.Items.Add("Addd")
Case 1
CheckedListBox1.Items.Add("Baaa")
CheckedListBox1.Items.Add("Bbbb")
CheckedListBox1.Items.Add("Bccc")
CheckedListBox1.Items.Add("Bddd")
Case 2
CheckedListBox1.Items.Add("Caaa")
CheckedListBox1.Items.Add("Cbbb")
CheckedListBox1.Items.Add("Cccc")
CheckedListBox1.Items.Add("Cddd")
End Select
End Sub
2、双击Button1输入一下代码
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (CheckedListBox1.GetItemChecked(0)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Aaaa的结果"
End If
If (CheckedListBox1.GetItemChecked(1)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Abbb的结果"
End If
If (CheckedListBox1.GetItemChecked(2)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Accc的结果"
End If
If (CheckedListBox1.GetItemChecked(3)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Addd的结果"
End If
If (CheckedListBox1.GetItemChecked(0)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Baaa的结果"
End If
If (CheckedListBox1.GetItemChecked(1)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Bbbb的结果"
End If
If (CheckedListBox1.GetItemChecked(2)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Bccc的结果"
End If
If (CheckedListBox1.GetItemChecked(3)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Bddd的结果"
End If
If (CheckedListBox1.GetItemChecked(0)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Caaa的结果"
End If
If (CheckedListBox1.GetItemChecked(1)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Cbbb的结果"
End If
If (CheckedListBox1.GetItemChecked(2)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Cccc的结果"
End If
If (CheckedListBox1.GetItemChecked(3)) = True Then
Form2.Show()
Form2.TextBox1.Text = "这是Cddd的结果"
End If
End Sub
End Class
不知道错在哪里
[此贴子已经被作者于2016-5-10 23:06编辑过]