我想要做一个只能输入数字的自定义控件,但一直没成功,请大虾帮忙(在线等):
代码如下:
Public inputdatatype As String
Public Property Get text() As Variant
    text = Text1.text
End PropertyPublic Property Let text(ByVal vNewValue As Variant)
    Text1.text = vNewValue
    PropertyChanged "text"
End PropertyPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
      If inputdatatype = "type_number" Then
        If KeyCode < 48 Or KeyCode > 105 Or KeyCode > 57 And KeyCode < 96 Then
            Text1.text = Left(Text1.text, Len(Text1.text) - 1)
        End If
      End If
End SubPrivate Sub UserControl_Resize()
    Text1.Left = 0
    Text1.Top = 0
    Text1.Width = UserControl.Width
    Text1.Height = UserControl.Height
End Sub