實現(xiàn)上述功能的VB程序如下,但加框處代碼有錯,請改正。 Const n=10 Dim a(1To n) As Integer Private Sub Command1_Click ( ?。?br />Dim i As Integer,j As Integer,t As Integer Dim bottom As Integer '獲取排序前數(shù)據(jù)依次存儲在數(shù)組a中,并在文本框Text1中顯示。代碼略 bottom=n i=1 Do While i<=bottom-1 For j=bottom To i+1Step-1 If Then t=a(j):a(j)=a(j-1):a(j-1)=t ElseIf a(j)=a(j-1)Then'相鄰兩個數(shù)據(jù)相等,進(jìn)行剔除處理
bottom=bottom-1 End If Next j i=i+1 Loop Text2.Text=““ For i=1To bottom Text2.Text=Text2.Text+Str(a(i)) Next i End Sub。
(2)請在橫線處填上合適的代碼 Const MIN_ASC=65 Function X2D(x As String) As String Dim s As String,zf As String,i As Integer s=““ For i=1To Len(x) zf=Mid(x,i,1) If zf>=“a“And zf<=“z“Then s=s+①
Else s=s+zf End If Next i X2D=s End Function Private Sub Command1_Click ( ) Dim M As String,K As String,C As String,flag As Boolean Dim i As Integer,t As Integer,ch As Integer,pos As Integer,j As Integer M=Text1.Text'明文 K=Text2.Text'密鑰 t=Len(K) K=X2D(K) C=““ For i=1To Len(M) ch=Asc(Mid(M,i,1)) flag=False If ch>=97And ch<=122Then ch=ch-32:flag=True pos=②
'密鑰的字符位置值 If pos=0Then pos=t j=Asc(Mid(K,pos,1))'密鑰字符的ASCII值 ch=ch-MIN_ASC j=j-MIN_ASC ch=③
ch=ch+MIN_ASC If flag Then ch=ch+32'設(shè)置字母的大小寫形式 C=C & Chr(ch) Next i Text3.Text=C End Sub