如何把VB的运行结果复制到剪贴板中
PrivateSubCommand1_Click()a="abcd"b="efgh"d=a&bPrintdEndSub我们知道,在VB中输入这段程序运行后的结果是输出“a...
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Print d
End Sub
我们知道,在VB中输入这段程序运行后的结果是输出“abcdefg”,请问,如何编写程序,能在上面这段程序运行之后把结果“abcdefg”复制到剪贴板中。
之后
用
Shell "notepad"
这个语句能新建一个记事本,如何编写VB程序,在判断新建的记事本已打开之后,将复制到剪贴板中的“abcdefg”粘贴到新建的记事本中。 展开
a = "abcd"
b = "efgh"
d = a & b
Print d
End Sub
我们知道,在VB中输入这段程序运行后的结果是输出“abcdefg”,请问,如何编写程序,能在上面这段程序运行之后把结果“abcdefg”复制到剪贴板中。
之后
用
Shell "notepad"
这个语句能新建一个记事本,如何编写VB程序,在判断新建的记事本已打开之后,将复制到剪贴板中的“abcdefg”粘贴到新建的记事本中。 展开
6个回答
展开全部
VB妮可 的方法确实可行
Shell "notepad", 1
SendKeys "^" + "V"
不过这样用很容易由于系统延迟出问题
Ctrl+V不一定使用在记事本上
推荐用API,效果较好,不容易出错
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PASTE = &H302
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Shell "notepad", vbNormalFocus
Call SendMessage(FindWindowEx(FindWindow(vbNullString, "无标题 - 记事本"), 0, "Edit", vbNullString), WM_PASTE, 0, 0&)
End Sub
Shell "notepad", 1
SendKeys "^" + "V"
不过这样用很容易由于系统延迟出问题
Ctrl+V不一定使用在记事本上
推荐用API,效果较好,不容易出错
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PASTE = &H302
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Shell "notepad", vbNormalFocus
Call SendMessage(FindWindowEx(FindWindow(vbNullString, "无标题 - 记事本"), 0, "Edit", vbNullString), WM_PASTE, 0, 0&)
End Sub
展开全部
clipboard.settext d '复制d这个变量到剪贴板中,clipboard为剪贴板
open 文本文件地址(包括扩展名) for output as 1
print #1,clipboard.gettext
close #1
上面为新建一个文本,路径自设,再将剪贴板内容复制保存
若想用shell的话,可以这样
Shell "notepad.exe " & xx, vbNormalFocus
SendKeys "^" + "V" '发送ctrl+V (粘贴)
xx为文本文件的地址,要绝对路径。
自己参考一下吧!很多方法
open 文本文件地址(包括扩展名) for output as 1
print #1,clipboard.gettext
close #1
上面为新建一个文本,路径自设,再将剪贴板内容复制保存
若想用shell的话,可以这样
Shell "notepad.exe " & xx, vbNormalFocus
SendKeys "^" + "V" '发送ctrl+V (粘贴)
xx为文本文件的地址,要绝对路径。
自己参考一下吧!很多方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2016-02-22
展开全部
Shell "notepad", 1
SendKeys "^" + "V"
不过这样用很容易由于系统延迟出问题
Ctrl+V不一定使用在记事本上
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PASTE = &H302
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Shell "notepad", vbNormalFocus
Call SendMessage(FindWindowEx(FindWindow(vbNullString, "无标题 - 记事本"), 0, "Edit", vbNullString), WM_PASTE, 0, 0&)
End Sub
SendKeys "^" + "V"
不过这样用很容易由于系统延迟出问题
Ctrl+V不一定使用在记事本上
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PASTE = &H302
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Shell "notepad", vbNormalFocus
Call SendMessage(FindWindowEx(FindWindow(vbNullString, "无标题 - 记事本"), 0, "Edit", vbNullString), WM_PASTE, 0, 0&)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Clipboard.SetText d
就行了
就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Print d
Clipboard.Clear
Clipboard.SetText d
Shell "notepad", 1
SendKeys "^" + "V"
End Sub
a = "abcd"
b = "efgh"
d = a & b
Print d
Clipboard.Clear
Clipboard.SetText d
Shell "notepad", 1
SendKeys "^" + "V"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询