⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbinput.bas

📁 普通波形发生器 开发环境:VisualBadsic
💻 BAS
字号:
Attribute VB_Name = "VBINPUT"
'****************************************************************************
'人人为我,我为人人
'枕善居汉化收藏整理
'发布日期:2007/05/25
'描    述:普通波形发生器 Version 1.0
'网    站:http://www.Mndsoft.com/  (VB6源码博客)
'网    站:http://www.VbDnet.com/   (VB.NET源码博客,主要基于.NET2005)
'e-mail  :Mndsoft@163.com
'e-mail  :Mndsoft@126.com
'OICQ    :88382850
'          如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Sub IntKP(ThisControl As Control, Length%, KeyAscii As Integer)
    
    If Len(ThisControl.Text) >= Length% Then
        KeyAscii = 0
        Beep
        Exit Sub
    End If
    
    If Len(ThisControl.Text) = Length% Then
      If KeyAscii <> 8 Then
        KeyAscii = 0
        Beep
      End If
    Else
      c$ = Chr$(KeyAscii)
      Select Case c$
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
        Case "-"
          If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
            KeyAscii = 0
            Beep
          End If
        Case Else
          KeyAscii = 0
          Beep
      End Select
    End If
End Sub

'Point2
'  Sub PointKP(ThisControl, Length%, DecimalNum,KeyAscii)
'  Function PointLF(ThisControl, Min$, Max$)
'  Accepts number with DecimalNum digits to the right of the decimal point.
'  Maximum length = Length%
'  Minimum value = Min$
'  Maximum value = Max$
'  Example 123.49
'
Sub PointKP(ThisControl As Control, Length%, DecimalNum%, KeyAscii As Integer)
    
    If KeyAscii = 13 Then Exit Sub ' Allow The ENTER key
    If KeyAscii = 8 Then Exit Sub ' Allow The BACKspace key
    
    If Len(ThisControl.Text) >= Length% Then
        KeyAscii = 0
        Beep
        Exit Sub
    End If
    
    If Len(ThisControl.Text) <> Length% Then
      StringLength% = Len(ThisControl.Text)
      DecimalPosition% = InStr(ThisControl.Text, ".")
      If StringLength% - DecimalPosition% = DecimalNum% And DecimalPosition% <> 0 Then
        If ThisControl.SelStart < DecimalPosition% Then
          Select Case KeyAscii
            Case 48 To 57
            Case 45 ' "-"
              If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
                KeyAscii = 0
                Beep
              End If
            Case Else
              KeyAscii = 0
              Beep
          End Select
        ElseIf KeyAscii <> 8 Then
          KeyAscii = 0
          Beep
        End If
      Else
        Select Case KeyAscii
          Case 48 To 57
          Case 46 ' "."
            If InStr(ThisControl.Text, ".") <> 0 Then
              KeyAscii = 0
              Beep
            End If
          Case 45
            If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
              KeyAscii = 0
              Beep
            End If
          Case Else
            KeyAscii = 0
            Beep
        End Select
      End If
    End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -