嗨,我是使用excel vba的新手,我制作了一个项目,该项目会将我的数据从woksheet显示到listView。现在,我想使用用户表单更新工作表上的数据。
当我单击列表视图上的任何客户,然后单击选择按钮时,它将获取数据,并且将在文本框中,因此,我现在可以进行更新了。但是当我单击更新按钮时,它有错误。这些是我的代码
选择按钮:
Private Sub select_Click()
Dim item As listItem
ListView1.SetFocus
Dim myindex As Integer
TextBox3.Text = Me.ListView1.SelectedItem
myindex = Me.ListView1.SelectedItem.Index
TextBox4.Text =
Me.ListView1.ListItems.item(myindex).SubItems(1)
TextBox5.Text =
Me.ListView1.ListItems.item(myindex).SubItems(2)
TextBox14.Text =
Me.ListView1.ListItems.item(myindex).SubItems(3)
TextBox7.Text =
Me.ListView1.ListItems.item(myindex).SubItems(4)
TextBox8.Text =
Me.ListView1.ListItems.item(myindex).SubItems(5)
TextBox9.Text =
Me.ListView1.ListItems.item(myindex).SubItems(6)
TextBox10.Text =
Me.ListView1.ListItems.item(myindex).SubItems(7)
TextBox11.Text =
Me.ListView1.ListItems.item(myindex).SubItems(8)
TextBox12.Text =
Me.ListView1.ListItems.item(myindex).SubItems(9)
TextBox13.Text =
Me.ListView1.ListItems.item(myindex).SubItems(10)
End Sub
更新按钮:
Private Sub Update_Click()
Dim customer As String, pickup As String,
delivery_date As String, load As String, place As.
String, bags As String, amount As String, status As.
String, checkno As String, checkdate As String, note.
As String
Dim currentrow As Long
customer = TextBox3.Text
Cells(currentrow, 1).Value
pickup = TextBox4.Text
Cells(currentrow, 2).Value = pickup
delivery_date = TextBox5.Text
Cells(currentrow, 3).Value = delivery_date
load = TextBox14.Text
Cells(currentrow, 4).Value = load
place = TextBox7.Text
Cells(currentrow, 5).Value = place
bags = TextBox8.Text
Cells(currentrow, 6).Value = bags
amount = TextBox9.Text
Cells(currentrow, 7).Value = amount
status = TextBox10.Text
Cells(currentrow, 8).Value = status
checkno = TextBox11.Text
Cells(currentrow, 9).Value = checkno
checkdate = TextBox12.Text
Cells(currentrow, 10).Value = checkdate
note = TextBox13.Text
Cells(currentrow, 11).Value = note
End Sub
请帮助我。预先谢谢你