Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim NString: NString = "A1LSK2DJF4HGP3QWO5EIR6UTYZ8MXN7CBV9"
Dim CString: CString = "SU7CSJKF09NCSDO9SDF09SDRLVK7809S4NF"
Dim Name: Name = Text1.Text
Dim msg1
Dim NChar, CChar
Dim Nnum
If Len(Name) < 1 Or Len(Name) > 7 Then
msg1 = MsgBox("必须输入1至7个英文字符!点击确定按钮重新输入,点击取消则默认用户名为“wapojie”,注册码为“9SSSF0F”!", 1, "注意")
If msg1 = 1 Then
Text1.SetFocus
Text1.Text = ""
End If
If msg1 = 2 Then
Text1.Text = "wapojie"
Text2.Text = "9SSSF0F"
Exit Sub
End If
End If
For i = 1 To Len(Name)
NChar = Mid(Name, i, 1)
If Asc(NChar) > 90 Then NChar = Chr(Asc(NChar) - 32)
Nnum = InStr(1, NString, NChar)
CChar = CChar & Mid(CString, Nnum, 1)
Next i
Text2.Text = Trim(CChar)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Or KeyAscii = 127 Then Exit Sub '如果输入退格键和删除键则退出过程
If KeyAscii < 65 Or KeyAscii > 122 Then KeyAscii = 0 '如果超出范围则无效,需重新输入新的字符
End Sub