乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 13|回复: 0

pastespec命令

[复制链接]

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2006-3-29 20:22:00 | 显示全部楼层 |阅读模式
回帖发生错误;我重新发了:)
GetFormat、GetText 和 SetText 方法示例
下例用 GetFormat、GetText 和 SetText 方法在 DataObject 和剪贴板之间传输文本。
用户把文本键入文本框然后单击 CommandButton1,把文本以标准文本格式传输到 DataObject。单击 CommandButton2,在 DataObject 中检索文本。单击 CommandButton3,用自定义格式把文本从 TextBox1 复制到 DataObject。单击 CommandButton4,用自定义格式在 DataObject 中检索文本。
若要使用该示例,请将示例代码复制到某窗体的声明变量部分。请确保该窗体包含:
名为 TextBox1 的文本框。

名为 CommandButton1 到 CommandButton4 的四个命令按钮控件。

名为 Label1 的标签。
Dim MyDataObject As DataObject
Private Sub CommandButton1_Click()
'把标准格式放到剪贴板上
    If TextBox1.TextLength > 0 Then
        Set MyDataObject = New DataObject
        MyDataObject.SetText TextBox1.Text
        Label1.Caption = "Put on D.O."
        CommandButton2.Enabled = True
        CommandButton4.Enabled = False
    End If
End Sub
Private Sub CommandButton2_Click()
'从剪切板得到标准格式
    If MyDataObject.GetFormat(1) = True Then
        Label1.Caption = "Std format - "_
            & MyDataObject.GetText(1)
    End If
End Sub
Private Sub CommandButton3_Click()
'把自定义格式放到剪切板上
    If TextBox1.TextLength > 0 Then
        Set MyDataObject = New DataObject
        MyDataObject.SetText TextBox1.Text, 233
        Label1.Caption = "Custom on D.O."
        CommandButton4.Enabled = True
        CommandButton2.Enabled = False
    End If
End Sub
Private Sub CommandButton4_Click()
'从剪切板得到自定义格式
    If MyDataObject.GetFormat(233) = True Then
        Label1.Caption = "Cust format - "_  
            & MyDataObject.GetText(233)
End If
End Sub
Private Sub UserForm_Initialize()
    CommandButton2.Enabled = False
    CommandButton4.Enabled = False
End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 06:27 , Processed in 1.356081 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表