[说明] 字符组合:程序界面如图示,在文本框Text1中输入若干个任意字符,单击“颠倒”按钮,将这些字符按相反的顺序显示在标签Lable1 中,并在标签Labs1 2处显示字符的个数。例如:输入abcabc2,显示为 2cbabca,组成字符数为4。
[Visual Basic 代码] Private Sub cmdshow_ Click ( Dim n As Integer Dim I As Integer Dim str1 As String N=Len ( Text1.Text ) For I=n To Step- 1 Str1= (1) Next I Labe11. Caption=Str1 End Sub Private Sub cmdcount_ Click ( ) Dim n As Integer Dim in As Integer Dim i As Integer Dim j As Integer Dim flag As Integer Dim str1 As Integer Dim str2 As Integer N= (2) Str1 =Mid$ ( Text1.Text, i. 1 For I =2 To n Str2=mid$ ( Text1,Text,I,1 M=Len (str1) (3) For j=1 To mIf (4) Then flag= 1; Exit For Next j If flag<>1 then str1=str1& str2 Next I Lable2.Caption= (5) End Sub
参考答案:(A) StrA& Mid $ (TextA.Text,I,A) (B) Len (TextA.Text)
解析:(3) Flag=0 (4) str 2=Mid $(str1,j,1) (5) Str $(Len (str1))