Private Sub Text1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)    If Button = 1 Then Exit Sub
    OldWindowProc = GetWindowLong(Text1.hWnd, GWL_WNDPROC)
    Call SetWindowLong(Text1.hWnd, GWL_WNDPROC, AddressOf SubClass1_WndMessage)End SubPrivate Sub Text1_MouseUp(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    If Button = 1 Then Exit Sub
    Call SetWindowLong(Text1.hWnd, GWL_WNDPROC, OldWindowProc)End Sub在使用MouseDown和MouseUp事件控制文本框输入格式时,如果文本框控件是数组(Text1(0-n)),总提示找不到方法和数据成员,要如何才能在这两个事件中使用数组控件?请高人指点一下,谢谢!

解决方案 »

  1.   

    参数 Index 就是控件数组中的第 Index + 1 个
    引用的时候需要加括号:Text1(Index).hWnd
      

  2.   


    Private Sub Text1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
        for index = 0 to n
            If Button = 1 Then Exit Sub
            OldWindowProc = GetWindowLong(Text1(index).hWnd, GWL_WNDPROC)
            Call SetWindowLong(Text1(index).hWnd, GWL_WNDPROC, AddressOf SubClass1_WndMessage)
        next
    End SubPrivate Sub Text1_MouseUp(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
        for index = 0 to n
          If Button = 1 Then Exit Sub
          Call SetWindowLong(Text1(index).hWnd, GWL_WNDPROC, OldWindowProc)
        next
    End Sub