如何用vb做个快速复制的程序?

如何用vb做个快速复制的程序?,第1张

1.在你的窗体上面一个文本框,然后复制粘贴,需要几个就粘贴几个,粘贴的时候会提示你是否要创建一个控件数组?选择“是”。

2.双击text1,然后输入如下代码:

Private Sub Text1_Change(Index As Integer)

Clipboard.SetText TxtUser(Index).Text

End Sub

3.运行后单击测试通过

(删除原来的进程, 重新打开新的进程可勉强实现)

Option Explicit

'窗口焦点设置

Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

'Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

'显示窗口

Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Public Const SW_HIDE = 0

Public Const SW_SHOWNORMAL = 1

Public Const SW_SHOWMINIMIZED = 2

Public Const SW_SHOWMAXIMIZED = 3

Public Const SW_MAXIMIZE = 3

Public Const SW_SHOWNOACTIVATE = 4

Public Const SW_SHOW = 5

Public Const SW_MINIMIZE = 6

Public Const SW_SHOWMINNOACTIVE = 7

Public Const SW_SHOWNA = 8

Public Const SW_RESTORE = 9

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst WM_CLOSE = &H10

Public lHwnd As Long

Public sHwnd As String

Sub Main()

lHwnd = 0

lHwnd = FindWindow(vbNullString, "form1")

If lHwnd >0 Then

'MsgBox "app exit " &CStr(lHwnd)

'ShowWindow lHwnd, SW_SHOW '用showwindow方法没有效果

'删除原来的进程, 重新打开新的进程

SendMessage lHwnd, WM_CLOSE, 0, 0

Form1.Show

Else

Form1.Show

End If

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11809662.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存