Private Sub Command1_Click() s = Text1.Text For i = 1 To Len(s) If Mid(s, i, 1) >= "A" And Mid(s, i, 1) <= "Z" Then If Mid(s, i, 1) <= "V" Then Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) + 4) Else Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) - 22) End If Else If Mid(s, i, 1) >= "a" And Mid(s, i, 1) <= "z" Then If Mid(s, i, 1) <= "v" Then Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) + 4) Else Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) - 22) End If End If End If Next i Text2.Text = sEnd Sub
Private Sub Command2_Click() s = Text2.Text For i = 1 To Len(s) If Mid(s, i, 1) >= "A" And Mid(s, i, 1) <= "Z" Then If Mid(s, i, 1) >= "E" Then Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) - 4) Else Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) + 22) End If Else If Mid(s, i, 1) >= "a" And Mid(s, i, 1) <= "z" Then If Mid(s, i, 1) >= "e" Then Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) - 4) Else Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) + 22) End If End If End If Next i Text3.Text = sEnd Sub
第二题:Private Sub Command1_Click() For i = 1 To 1000 s1 = Trim(Str(i)) s2 = Trim(Str(i * i)) k1 = Len(s1) k2 = Len(s2) If Mid(s2, k2 - k1 + 1, k1) = s1 Then Print i Next iEnd Sub