Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call addsub()
End Sub
Dim listbox1 As New ListBox() 'new listbox()在这里是什么意思?()表示的有时什么
Dim textbox1 As New TextBox()
Dim labell As New Label()
Dim button1 As New Button()
Dim button2 As New Button()
Dim button3 As New Button()
Dim button4 As New Button()
Dim button5 As New Button()
Dim button6 As New Button()
Private Sub addsub()
listbox1.Size = New System.Drawing.Size(200, 200) '为什么不可以是listbox1.size=(200,200) new在这里是什么意思?
listbox1.Location = New System.Drawing.Point(10, 30)
Me.Controls.Add(listbox1)
listbox1.MultiColumn = True
listbox1.ColumnWidth = 80
listbox1.SelectionMode = SelectionMode.MultiExtended
listbox1.BeginUpdate()
Dim x As Integer
For x = 1 To 50
listbox1.Items.Add("items " & x.ToString()) 'x.tostring是什么意思
Next x 'next x 又是什么意思?
listbox1.EndUpdate()
'创建和添加一个textbox空间并设置其属性
textbox1.Size = New.D Systemrawing.Size(200, 20)
textbox1.Location = New System.Drawing.Point(10, 240)
Me.Controls.Add(textbox1)
textbox1.Multiline = False
textbox1.Text = ""
'创建和添加一个label空间,并设置其属性
labell.Size = New System.Drawing.Size(200, 20)
labell.Location = New System.Drawing.Point(10, 5)
Me.Controls.Add(labell)
labell.Text = ""
button1.Size = New System.Drawing.Size(60, 30)
button1.Location = New System.Drawing.Point(220, 20)
button2.Size = New System.Drawing.Size(60, 30)
button2.Location = New System.Drawing.Point(220, 60)
button3.Size = New System.Drawing.Size(60, 30)
button3.Location = New System.Drawing.Point(220, 100)
button4.Size = New System.Drawing.Size(60, 30)
button4.Location = New System.Drawing.Point(220, 140)
button5.Size = New System.Drawing.Size(60, 30)
button5.Location = New System.Drawing.Point(220, 180)
button6.Size = New System.Drawing.Size(60, 30)
button6.Location = New System.Drawing.Point(220, 220)
Me.Controls.Add(button1)
Me.Controls.Add(button2)
Me.Controls.Add(button3)
Me.Controls.Add(button4)
Me.Controls.Add(button5)
Me.Controls.Add(button6)
button1.Text = "排序"
button2.Text = "删除"
button3.Text = "插入"
button4.Text = "添加"
button5.Text = "查找"
button6.Text = "重做"
AddHandler button1.Click, New System.EventHandler(AddressOf Me.button1_click)
AddHandler button2.Click, New System.EventHandler(AddressOf Me.button2_click)
AddHandler button3.Click, New System.EventHandler(AddressOf Me.button3_click)
AddHandler button4.Click, New System.EventHandler(AddressOf Me.button4_click)
AddHandler button5.Click, New System.EventHandler(AddressOf Me.button5_click)
AddHandler button6.Click, New System.EventHandler(AddressOf Me.button6_click)
End Sub
Private Sub button1_click(ByVal sender As Object, ByVal e As System.EventArgs)
listbox1.Sorted = True
End Sub
Private Sub button2_click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim i As Integer
i = listbox1.SelectedItems.Count
Do While i <> 0
labell.Text = listbox1.SelectedIndex
listbox1.Items.Remove(listbox1.SelectedItem)
i = i - 1
Loop
End Sub
Private Sub button3_click(ByVal sender As Object, ByVal e As System.EventArgs)
listbox1.Items.Insert(listbox1.SelectedIndex, textbox1.Text)
End Sub
Private Sub button4_click(ByVal sender As Object, ByVal e As System.EventArgs)
listbox1.Items.Add(textbox1.Text)
End Sub
Private Sub button5_click(ByVal sender As Object, ByVal e As System.EventArgs)
listbox1.FindString(textbox1.Text)
labell.Text = listbox1.FindString(textbox1.Text)
End Sub
Private Sub button6_click(ByVal sender As Object, ByVal e As System.EventArgs)
textbox1.Clear()
labell.Text = ""
End Sub
End Class
1、Dim listbox1 As New ListBox()
new listbox()在这里是什么意思?()表示的又是什么
2、Call addsub()又是什么意思?
3、Me.Controls.Add(button1)
和 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
又有什么区别?功能应该是一样的吧?
4、AddHandler button1.Click, New System.EventHandler(AddressOf Me.button1_click)
是什么意思?