求word控件 vba 或 vb 编程的大大

来源:百度知道 编辑:UC知道 时间:2024/05/06 01:17:30
在word中加个小控件 2个单选框,2个文本框,2个按钮(输出,清除)
按下输出,把文本框1和2个单选框的内容显示到文本框2中,并且文本框1中内容清除,单选框复位,按下清除则清除文本框2中的内容。
请大家帮忙谢谢

其实VBA与VB差不多,代码如下:
两个单选框:名称 optOne和optTwo
两个文本框:名称 txtOne和txtTwo
两个按钮:名称 cmdPost和cmdClear
'输出按钮
Private Sub cmdPost_Click()
'文本框1和2个单选框的内容显示到文本框2中
If optOne.Value=1 And optTwo.Value=1 Then
txtTwo.Text=txtOne.Text & optOne.Caption & optTwo.Caption
Else If optOne.Value=1 Then
txtTwo.Text=txtOne.Text & optOne.Caption
Else If optTwo.Value=1 Then
txtTwo.Text=txtOne.Text & optTwo.Caption
End If
'文本框1中内容清除
txtOne.Text=""
'单选框复位
optOne.Value=0
optTwo.Value=0
End Sub

Private Sub cmdClear_Click()
'清除文本框2中的内容
txtTwo.Text=""
End Sub