题目

(消失的pigs)用VB编写程序实现:从某一字符串中删除指定的字符串,并将处理后的字符串重新输出。程序界面如图1所示,在文本框Text1中输入原始字符串,在文本框Text2中输入需要删除的字符串,单击“删除字符串”按钮Command1后,在文本框Text3中输出处理后的结果。 图1 (1) 在设计应用程序界面时,应使用图2所示“控件工具箱”中的(填写相应编号)添加按钮。 图2 (2) 窗体按钮上显示的文字“删除字符串”是需要修改按钮Command1的属性值修改为“删除字符串”。 (3) 为实现上述功能,请在划线处填入合适的代码。 Private Sub Command1_Click()   Dim s As Integer, r As Integer, c As Integer   Dim source As String, delstr As String, ch As String   c = 0: i = 1   source = Text1.Text:delstr = Text2.Text   s = Len(source)   r = Len(delstr)   Do While s-i+1 >= r     ch = Mid(source, i, r)     If ch = delstr Then         source = Mid(source,1, i-1) +         s = Len(source)               Else         i = i + 1     End If   Loop   Label4.Caption = "共删除:" + Str(c) + "处"   Text3.Text = source End Sub 答案: 【1】4 【1】Caption 【1】Mid(source,i+r,s)或Mid(source,i+r)【2】c=c+1
信息技术 试题推荐
最近更新