在窗体上画两个文本框(Text1和Text2)以及一个按钮(Command1),在Text1中输入love(或者是其它),单击按钮后即在Text2中输出密码Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim txtlen As Integer, i As Integer, _
j As Variant, k As Integer, l As Variant
Dim txt() '定义一个数组,用于储存Text2中的数据
Dim last() '定义一个数组,用于储存转换后的密码
txtlen = Len(Text1.Text) '确定Text2中字符的长短,以确定数组的大小
For i = 1 To txtlen '在数组txtlen中储存text1中的字符
ReDim Preserve txt(i)
txt(i) = Right(Left(Text1.Text, i), 1)
Next
For Each j In txt
k = k + 1
ReDim Preserve last(k)
last(k) = Chr(Asc(j) + 3) '转换为密码
Next
For Each l In last
Text2.Text = Text2.Text & l
Next
End Sub