Is the Clipboard Numeric?

DiverDan

Well-known member
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
User Rank
*Experts*
There are probably a ton of programmers that already do this, but since there is a concern in pasteing text in a textbox that only should accept numbers, heres how to check if the clipboard contains only a numeric value:

Check Clipboard
Dim ClipboardText As String
Dim data As IDataObject = Clipboard.GetDataObject()

If (data.GetDataPresent(DataFormats.Text)) Then
ClipboardText = data.GetData(DataFormats.Text).ToString()
If IsNumeric(ClipboardText) Then
EnablePaste()
Else
DisablePaste()
End If
End If

Hope this helps someone.
Dan
 
Back
Top