VB编程题
三、综合应用题在考生文件夹下有一个工程文件vbsj5.vbp及窗体文件vbsj5.frm。在名称为Form1的窗体上已有3个文本框Txt1、Txt2和Txt3,以及不完整...
三、综合应用题
在考生文件夹下有一个工程文件vbsj5.vbp及窗体文件vbsj5.frm。在名称为Form1的窗体上已有3个文本框Txt1、Txt2和Txt3,以及不完整的程序。请完成以下工作:
(1)在属性窗口中修改Txt3的适当属性,使其在运行时不显示.
图1-5
(2)建立下拉式菜单,菜单属性设置见表1-1。
表1-1 菜单属性
标题 名称
编辑 mnuEdit
复制 mnuEditCopy
剪切 mnuEditCut
粘贴 mnuEditPaste
(3)在窗体文件中给出了所有事件过程,但不完整,请删除程序中语句前面的注释符"'",把程序中的问号"?"改为正确的内容,但不得修改程序的其他部分,也不得修改控件的其他属性,并在原文件夹中按原文件名保存修改后的文件,以便实现以下功能:
当光标所在的文本框中无内容时,"剪切"和"复制"菜单项不可用,否则可以把该文本框中的内容剪切或复制到Txt3中;若Txt3中无内容,则"粘贴"菜单项不能用,否则可以把Txt3中的内容粘贴到光标所在的文本框中的内容之后。
程序源码:
Dim g_intno As Integer
Private Sub _
mnuEditCopy_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
End If
End Sub
Private Sub _
mnuEditCut_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
Txt1.Text = ""
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
Txt2.Text = ""
End If
End Sub
Private Sub mnuEdit_Click()
' If g_intno = ? Then
If Txt1.Text = "" Then
mnuEditCut.Enabled=False
mnuEditCopy.Enabled=False
Else
mnuEditCut.Enabled=True
mnuEditCopy.Enabled = True
End If
' ElseIf g_intno = ? Then
If Txt2.Text = "" Then
mnuEditCut.Enabled=False
mnuEditCopy.Enabled=False
Else
mnuEditCut.Enabled=True
mnuEditCopy.Enabled=True
End If
End If
If Txt3.Text = "" Then
mnuEditPaste.Enabled=False
Else
mnuEditPaste.Enabled=True
End If
End Sub
Private Sub mnuEditPaste_Click()
If g_intno = 1 Then
' Txt1.Text = ?
ElseIf g_intno = 2 Then
' Txt2.Text = ?
End If
End Sub
Private Sub Txt1_GotFocus()
g_intno = 1
End Sub
Private Sub Txt2_GotFocus()
g_intno = 2
End Sub
这道题的程序怎么改,高手帮忙 展开
在考生文件夹下有一个工程文件vbsj5.vbp及窗体文件vbsj5.frm。在名称为Form1的窗体上已有3个文本框Txt1、Txt2和Txt3,以及不完整的程序。请完成以下工作:
(1)在属性窗口中修改Txt3的适当属性,使其在运行时不显示.
图1-5
(2)建立下拉式菜单,菜单属性设置见表1-1。
表1-1 菜单属性
标题 名称
编辑 mnuEdit
复制 mnuEditCopy
剪切 mnuEditCut
粘贴 mnuEditPaste
(3)在窗体文件中给出了所有事件过程,但不完整,请删除程序中语句前面的注释符"'",把程序中的问号"?"改为正确的内容,但不得修改程序的其他部分,也不得修改控件的其他属性,并在原文件夹中按原文件名保存修改后的文件,以便实现以下功能:
当光标所在的文本框中无内容时,"剪切"和"复制"菜单项不可用,否则可以把该文本框中的内容剪切或复制到Txt3中;若Txt3中无内容,则"粘贴"菜单项不能用,否则可以把Txt3中的内容粘贴到光标所在的文本框中的内容之后。
程序源码:
Dim g_intno As Integer
Private Sub _
mnuEditCopy_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
End If
End Sub
Private Sub _
mnuEditCut_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
Txt1.Text = ""
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
Txt2.Text = ""
End If
End Sub
Private Sub mnuEdit_Click()
' If g_intno = ? Then
If Txt1.Text = "" Then
mnuEditCut.Enabled=False
mnuEditCopy.Enabled=False
Else
mnuEditCut.Enabled=True
mnuEditCopy.Enabled = True
End If
' ElseIf g_intno = ? Then
If Txt2.Text = "" Then
mnuEditCut.Enabled=False
mnuEditCopy.Enabled=False
Else
mnuEditCut.Enabled=True
mnuEditCopy.Enabled=True
End If
End If
If Txt3.Text = "" Then
mnuEditPaste.Enabled=False
Else
mnuEditPaste.Enabled=True
End If
End Sub
Private Sub mnuEditPaste_Click()
If g_intno = 1 Then
' Txt1.Text = ?
ElseIf g_intno = 2 Then
' Txt2.Text = ?
End If
End Sub
Private Sub Txt1_GotFocus()
g_intno = 1
End Sub
Private Sub Txt2_GotFocus()
g_intno = 2
End Sub
这道题的程序怎么改,高手帮忙 展开
1个回答
展开全部
Dim g_intno As Integer
Private Sub _
mnuEditCopy_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
End If
End Sub
Private Sub _
mnuEditCut_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
Txt1.Text = ""
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
Txt2.Text = ""
End If
End Sub
Private Sub mnuEdit_Click()
If g_intno = 1 Then '?修改为 1
If Txt1.Text = "" Then
mnuEditCut.Enabled = False
mnuEditCopy.Enabled = False
Else
mnuEditCut.Enabled = True
mnuEditCopy.Enabled = True
End If
ElseIf g_intno = 2 Then '?修改为 2
If Txt2.Text = "" Then
mnuEditCut.Enabled = False
mnuEditCopy.Enabled = False
Else
mnuEditCut.Enabled = True
mnuEditCopy.Enabled = True
End If
End If
If Txt3.Text = "" Then
mnuEditPaste.Enabled = False
Else
mnuEditPaste.Enabled = True
End If
End Sub
Private Sub mnuEditPaste_Click()
If g_intno = 1 Then
Txt1.Text = Txt3.Text '?修改为 Txt3.Text
ElseIf g_intno = 2 Then
Txt2.Text = Txt3.Text '?修改为 Txt3.Text
End If
End Sub
Private Sub Txt1_GotFocus()
g_intno = 1
End Sub
Private Sub Txt2_GotFocus()
g_intno = 2
End Sub
(PS:我真无聊....>_<)
Private Sub _
mnuEditCopy_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
End If
End Sub
Private Sub _
mnuEditCut_Click()
If g_intno = 1 Then
Txt3.Text = Txt1.Text
Txt1.Text = ""
ElseIf g_intno = 2 Then
Txt3.Text = Txt2.Text
Txt2.Text = ""
End If
End Sub
Private Sub mnuEdit_Click()
If g_intno = 1 Then '?修改为 1
If Txt1.Text = "" Then
mnuEditCut.Enabled = False
mnuEditCopy.Enabled = False
Else
mnuEditCut.Enabled = True
mnuEditCopy.Enabled = True
End If
ElseIf g_intno = 2 Then '?修改为 2
If Txt2.Text = "" Then
mnuEditCut.Enabled = False
mnuEditCopy.Enabled = False
Else
mnuEditCut.Enabled = True
mnuEditCopy.Enabled = True
End If
End If
If Txt3.Text = "" Then
mnuEditPaste.Enabled = False
Else
mnuEditPaste.Enabled = True
End If
End Sub
Private Sub mnuEditPaste_Click()
If g_intno = 1 Then
Txt1.Text = Txt3.Text '?修改为 Txt3.Text
ElseIf g_intno = 2 Then
Txt2.Text = Txt3.Text '?修改为 Txt3.Text
End If
End Sub
Private Sub Txt1_GotFocus()
g_intno = 1
End Sub
Private Sub Txt2_GotFocus()
g_intno = 2
End Sub
(PS:我真无聊....>_<)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询