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

📄 basedit.bas

📁 程序加密算法
💻 BAS
📖 第 1 页 / 共 2 页
字号:
End Sub

Public Function CenterText(ByVal strInput As String, _
                           Optional ByVal intAreaWidth As Integer = 80)
    
' ***************************************************************************
' Routine:       CenterText
'
' Description:   Center text on a line.
'
' Parameters:    strInput - Data to be centered
'                intAreaWidth - length of line to have the data centered in
'
' Returns:       Centered text on a line.
'
' ===========================================================================
'    DATE      NAME / DESCRIPTION
' -----------  --------------------------------------------------------------
' 02-JUL-1998  Kenneth Ives  kenaso@home.com
'              Original routine
' ***************************************************************************

' ---------------------------------------------------------------------------
' Define local variables
' ---------------------------------------------------------------------------
  Dim intRemainder  As Integer
  Dim strTmp        As String
    
' ---------------------------------------------------------------------------
' Subtract the length of the incoming string from the max length allowed
' ---------------------------------------------------------------------------
  strTmp = ""
  intRemainder = intAreaWidth - Len(strInput)
    
' ---------------------------------------------------------------------------
' If there is something left over then calculate half of that value and
' prefix the string with appropriate number of blank spaces.  Then append
' some trailing blank spaces.  The extra will be removed.
' ---------------------------------------------------------------------------
  If intRemainder > 0 Then
      strTmp = Space$(intRemainder \ 2) & strInput & Space$(intAreaWidth)
  Else
      strTmp = strInput
  End If
    
' ---------------------------------------------------------------------------
' Return the centered text string entirely.
' ---------------------------------------------------------------------------
  CenterText = Left$(strTmp, intAreaWidth)
 
End Function


Public Sub Edit_Copy()

' ***************************************************************************
' Routine:       Edit_Copy
'
' Description:   Copy highlighted text to the clipboard. See Keydown event
'                for the text boxes to see an example of the code calling
'                this routine.
'
' Special Logic: When the user highlights text with the cursor and presses
'                CTRL+C to perform a copy function.  The highlighted text
'                is then loaded into the clipboard.
'
' ===========================================================================
'    DATE      NAME / DESCRIPTION
' -----------  --------------------------------------------------------------
' 02-JUL-1998  Kenneth Ives  kenaso@home.com
'              Original routine
' ***************************************************************************

' ---------------------------------------------------------------------------
' Verify this is a text box that the cursor is over
' ---------------------------------------------------------------------------
  If TypeOf Screen.ActiveControl Is TextBox Then
      '
      ' clear the clipboard
      Clipboard.Clear
      '
      ' load clipboard with the highlighted text
      Clipboard.SetText Screen.ActiveControl.SelText
  End If
  
End Sub

Public Sub Edit_Cut()

' ***************************************************************************
' Routine:       Edit_Cut
'
' Description:   Copy highlighted text to the clipboard and then remove it
'                from the text box. See Keydown event for the text boxes to
'                see an example of the code calling this routine.
'
' Special Logic: When the user highlights text with the cursor and presses
'                CTRL+X to perform a cutting function.  The highlighted text
'                is then moved to the clipboard.
'
' ===========================================================================
'    DATE      NAME / DESCRIPTION
' -----------  --------------------------------------------------------------
' 02-JUL-1998  Kenneth Ives  kenaso@home.com
'              Original routine
' ***************************************************************************

' ---------------------------------------------------------------------------
' Verify this is a text box that the cursor is over
' ---------------------------------------------------------------------------
  If TypeOf Screen.ActiveControl Is TextBox Then
      '
      ' clear the clipboard
      Clipboard.Clear
      '
      ' load clipboard with the highlighted text
      Clipboard.SetText Screen.ActiveControl.SelText
      '
      ' empty the textbox
      Screen.ActiveControl.SelText = ""
  End If

End Sub

Public Sub Edit_Delete()

' ***************************************************************************
' Routine:       Edit_Delete
'
' Description:   Copy highlighted text to the clipboard and then remove it
'                from the text box. See Keydown event for the text boxes to
'                see an example of the code calling this routine.
'
' Special Logic: When the user highlights text with the cursor and presses
'                CTRL+X to perform a cutting function.  The highlighted text
'                is then moved to the clipboard and the clipboard is emptied
'
' ===========================================================================
'    DATE      NAME / DESCRIPTION
' -----------  --------------------------------------------------------------
' 02-JUL-1998  Kenneth Ives  kenaso@home.com
'              Original routine
' ***************************************************************************

' ---------------------------------------------------------------------------
' Verify this is a text box that the cursor is over
' ---------------------------------------------------------------------------
  If TypeOf Screen.ActiveControl Is TextBox Then
      
      ' remove the highlighted text from the textbox
      Screen.ActiveControl.SelText = ""
  End If
  
End Sub

Public Sub Edit_Paste()

' ***************************************************************************
' Routine:       Edit_Paste
'
' Description:   Copy whatever text is being held in the clipboard and then
'                paste it in the text box. See Keydown event for the text
'                boxes to see an example of the code calling this routine.
'
' ===========================================================================
'    DATE      NAME / DESCRIPTION
' -----------  --------------------------------------------------------------
' 02-JUL-1998  Kenneth Ives  kenaso@home.com
'              Original routine
' ***************************************************************************

' ---------------------------------------------------------------------------
' Verify this is a text box that the cursor is over
' ---------------------------------------------------------------------------
  If TypeOf Screen.ActiveControl Is TextBox Then
      
      ' unload clipboard into the textbox
      Screen.ActiveControl.SelText = Clipboard.GetText()
  End If

End Sub

Private Sub Paste_In_GotFocus_Event()

' Paste this code in the text box GotFocus event
  
' ---------------------------------------------------------------------------
' Highlight all the text in the box
' ---------------------------------------------------------------------------
  SendKeys "{Home}{End}"
  
End Sub

Private Sub Paste_in_Text_KeyDown_Event(KeyCode As Integer, Shift As Integer)

' Paste this code in the text box KeyDown event

' ---------------------------------------------------------------------------
' Define local variables
' ---------------------------------------------------------------------------
  Dim CtrlDown    As Integer
  Dim PressedKey  As Integer
  
' ---------------------------------------------------------------------------
' Initialize  variables
' ---------------------------------------------------------------------------
  CtrlDown = (Shift And vbCtrlMask) > 0                 ' Define control key
  
  If Len(Trim$(KeyCode)) > 0 Then
      ' Convert to uppercase
      PressedKey = CInt(Asc(StrConv(Chr$(KeyCode), vbUpperCase)))
  End If
    
' ---------------------------------------------------------------------------
' Check to see if it is okay to make changes
' ---------------------------------------------------------------------------
  If CtrlDown And PressedKey = vbKeyX Then      ' Ctrl + X was pressed
      Edit_Cut
  ElseIf CtrlDown And PressedKey = vbKeyA Then  ' Ctrl + A was pressed
      SendKeys "{Home}{End}"
  ElseIf CtrlDown And PressedKey = vbKeyC Then  ' Ctrl + C was pressed
      Edit_Copy
  ElseIf CtrlDown And PressedKey = vbKeyV Then  ' Ctrl + V was pressed
      Edit_Paste
  ElseIf PressedKey = vbKeyDelete Then          ' Delete key was pressed
      Edit_Delete
  End If

End Sub

⌨️ 快捷键说明

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