十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Clipboard.SetDataObject(TextBox1.Text)
创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计制作、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的肃宁网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
复制textbox1.text的内容的剪贴板
Dim p1 As New Point(0, 0)
Dim p2 As New Point(My.Computer.Screen.WorkingArea.Width, My.Computer.Screen.WorkingArea.Height) '除工具栏全屏
Dim pic As New Bitmap(p2.X, p2.Y)
Using g As Graphics = Graphics.FromImage(pic)
g.CopyFromScreen(p1, p1, p2)
PictureBox1.Image = pic
End Using
Clipboard.SetImage(PictureBox1.Image)
截图到PictureBox1中显示,然后在把PictureBox1.image放到剪切板中
复制什么文件呢?
给你举个例子:复制音频文件
Public Class Form1
'VB.Net复制读取音频文件并复制到剪贴板
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim MyData As Byte()
MyMyData = My.Computer.FileSystem.ReadAllBytes("WindowsXP.wav")
My.Computer.Clipboard.SetAudio(MyData)
MessageBox.Show("已经成功将音频数据VB.Net复制到剪贴板!", "51cto提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("将音频数据复制到剪贴板出现错误,请检查音频文件是否已经存在?", "51cto提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'粘贴剪贴板音频数据并播放
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim MyData As Object
MyMyData = My.Computer.Clipboard.GetData(DataFormats.WaveAudio)
My.Computer.Audio.Play(MyData, AudioPlayMode.Background)
Catch ex As Exception
MessageBox.Show("剪贴板上不存在指定的音频数据!", "51cto提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'清空剪贴板上的音频数据
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Computer.Clipboard.Clear()
End Sub
End Class
完善一下答案,现在所谓的复制粘贴文件操作,只是复制文件的地址,然后copy到指定地址,你要做的就是把文件的地址复制到剪贴板就好。所谓的剪切,也就是copy后多了一个delete功能。大同小异。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Str As String = Clipboard.GetText '获取剪切板数据。
ListView1.View = View.Details
Dim Tit As Boolean = True
Dim Index As Integer = 0 '标题行的列数。
Try
For Each i In Str.Replace(vbLf, "").Split(vbCr)
Dim Str2() As String = i.Split(" ")
If Tit Then '标题行
Tit = False
For Each k In Str2
ListView1.Columns.Add(k)
Next
Index = Str2.Length - 1
Else '非标题行。
Dim lv As New ListViewItem(Str2(0))
For k = 1 To Index
lv.SubItems.Add(Str2(k))
Next
ListView1.Items.Add(lv)
End If
Next
Catch ex As Exception
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Clipboard.SetDataObject(TextBox1.Text)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox1.Text = Clipboard.GetDataObject().GetData(DataFormats.Text, False)
End Sub
例如,把文件"E:\新建文件夹\a.txt"复制到剪贴板
CreateObject("Shell.Application").NameSpace("E:\新建文件夹").ParseName("a.txt").InvokeVerb "复制(C)"