📄 dde.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "DDE"
ClientHeight = 3540
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3540
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "Command1"
Height = 300
Left = 2880
TabIndex = 2
Top = 3240
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 300
Left = 360
TabIndex = 1
Top = 3240
Width = 1215
End
Begin VB.TextBox Text1
Height = 3135
Left = 120
MultiLine = -1 'True
TabIndex = 0
Text = "DDE.frx":0000
Top = 0
Width = 4455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' 设置DDE对话信息并激活对话
Private Sub Form_Load()
Command1.Caption = "UpDate"
Command2.Caption = "Execute"
Text1.LinkTopic = "winword|c:\demo.doc" '设置连接主题
Text1.LinkTimeout = 100 '设置连接时间
Text1.LinkItem = "\Doc" '设置连接项目
Text1.LinkMode = 2 '设置连接模式
End Sub
' 确保服务程序已经运行
Private Sub Text1_LinkOpen(Cancel As Integer)
MsgBox "正在建立DDE连接,请确保服务程序已经运行", vbOKOnly, "DDE"
End Sub
' 更新文本框内容
Private Sub Command1_Click()
Text1.LinkRequest
End Sub
' 将命令字符串发送给发送端应用程序
Private Sub Command2_Click()
Dim Cmd As String
Cmd = "[EditSelectAll]" '选中所有内容
Cmd = Cmd & "[Bold]" '字体加粗
Cmd = Cmd & "[FileSave]" '保存
Text1.LinkExecute Cmd '执行命令
End Sub
' 当文本框内容改变时,将文本框内容内容传送给发送端应用程序
Private Sub Text1_Change()
Text1.LinkPoke
End Sub
' 当DDE对话出现错误时,显示错误信息
Private Sub Text1_LinkError(LinkErr As Integer)
Dim Msg As String
Select Case LinkErr
Case 1
Msg = "数据格式错误"
Case 11
Msg = "内存不足"
Case Else
Msg = "其他错误"
End Select
MsgBox Msg, vbExclamation, "DDE"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -