Home > Software engineering >  Programming VB beginner, could you tell me???????
Programming VB beginner, could you tell me???????

Time:11-19

[title] in the name of Form1 form to add a name to L1 list box, add a
'name for Text1 text box, add two names of C1 and C2 respectively command button,
'[for]
'(1) through the properties window to L1 add list item "AAA", "BBB", "CCC",
'(2) set the title of C1 and C2 button respectively "added list item" and "delete list items",
'(3) write the appropriate event process, when the program runs, to the text box input string "DDD"
List, click "add item" button to add the contents of the text box to the list box, click
'" delete list items "the selected list item in a list box to delete,

CodePudding user response:

Generation of homework belongs to charging projects

CodePudding user response:

Programming is
Option explicit
Private sub C1_click ()
L1. Additem text1. Text
End sub
Private sub C2_click ()
L1. Removeitem L1. Listindex
End sub
Why when deleting the wrong?

CodePudding user response:

L1. Removeitem L1. Listindex
Change
L1. Removeitem 0
Have a try?

Listindex in the absence of selected list elements may be 1.

CodePudding user response:

Try this:
Option Explicit
Dim x As Integer
Private Sub C1_click ()
L1. AddItem Text1. Text, L1. ListCount
X=L1. ListCount
End Sub
Private Sub C2_click ()
L1. RemoveItem (x - 1)
X=x - 1
End Sub

CodePudding user response:

refer to the second floor kollegu response:
programming is
Option explicit
Private sub C1_click ()
L1. Additem text1. Text
End sub
Private sub C2_click ()
L1. Removeitem L1. Listindex
End sub
Why when deleting the wrong?

Listindex refers to you in the selected list box item index, you don't select the default value is 1
  • Related