DiverDan
Contributor
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, here's 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
'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