Become a Premium Member and unlock a new, free course in leading technologies each month.
Go Premium for a chance to win a PS4. Enter to Win
Private Const CF_TEXT = 1
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Long, ByVal ByteLen As Long)
Private Sub Form_Load()
Dim hStrPtr As Long, lLength As Long, sBuffer As String
hStrPtr = GetClipboardData(CF_TEXT)
If hStrPtr <> 0 Then
lLength = lstrlen(hStrPtr)
If lLength > 0 Then
sBuffer = Space$(lLength)
CopyMemory ByVal sBuffer, ByVal hStrPtr, lLength
MsgBox sBuffer, vbInformation
Open in new window
We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.
Join & Ask a Question
Join our community for more solutions or to ask questions.
For immediate help use Live now!