如何在控件中实现按回车相当于点击鼠标确认
PrivateSubCommandButton1_Click()UnloadMeEndSubPrivateSubListView1_DblClick()pm=ListVi...
Private Sub CommandButton1_Click() Unload MeEnd SubPrivate Sub ListView1_DblClick() pm = ListView1.SelectedItem.Text Me.Hide MsgBox "双击:" & pmEnd SubPrivate Sub ListView1_KeyDown(KeyCode As Integer, ByVal Shift As Integer) If KeyCode = 13 Then MsgBox ListView1.SelectedItem.TextEnd Sub Private Sub TextBox1_Change() Dim Itm As ListItem, arr i = Sheet16.Cells(Rows.Count, 1).End(3).Row If i < 5 Then MsgBox "没有数据", 64, "提示": Exit Sub arr = Sheet16.Range("A5:p" & i) txt = Me.TextBox1.Text ReDim brr(1 To UBound(arr), 1 To 6) For y = 1 To UBound(arr) If InStr(arr(y, 2), txt) Then nc = nc + 1 For i = 1 To 4 brr(nc, i) = arr(y, i) Next If arr(y, 15) Then brr(nc, 5) = arr(y, 15) Else brr(nc, 5) = "" End If If arr(y, 16) Then brr(nc, 6) = arr(y, 16) Else brr(nc, 6) = "" End If End If Next With Me.ListView1 .ListItems.Clear If nc Then For n = 1 To nc Set Itm = .ListItems.Add() Itm.Text = brr(n, 1) For m = 1 To UBound(brr, 2) - 1 Itm.SubItems(m) = brr(n, m + 1) Next Next End If End WithEnd SubPrivate Sub UserForm_Initialize() Dim Itm As ListItem i = Sheet16.Cells(Rows.Count, 1).End(3).Row arr = Sheet16.Range("A5:p" & i) nrr = Array("品号", "物料名称", "规格型号", "单位", "结存数量", "结存金额") ReDim brr(1 To UBound(arr), 1 To UBound(nrr) + 1) For y = 1 To UBound(arr) For i = 1 To 4 brr(y, i) = arr(y, i) Next If arr(y, 15) Then brr(y, 5) = arr(y, 15) Else brr(y, 5) = "" End If If arr(y, 16) Then brr(y, 6) = arr(y, 16) Else brr(y, 6) = "" End If Next grr = Array(45, 100, 120, 28, 45, 55) Me.Width = 420 Me.ListView1.Width = 410 Me.ListView1.Left = 7.5 With Me.ListView1 .ColumnHeaders.Clear .ListItems.Clear For k = 0 To UBound(nrr) .ColumnHeaders.Add , , nrr(k), grr(k), lvwColumnLeft Next .Gridlines = True .View = lvwReport For n = 1 To UBound(arr) Set Itm = .ListItems.Add() Itm.Text = arr(n, 1) For m = 1 To UBound(brr, 2) - 1 Itm.SubItems(m) = brr(n, m + 1) Next Next End WithEnd Sub我的QQ是381129075
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询