Option ExplicitDim i As Integer Dim X As Integer Dim a() As String Dim t1 As String, t2 As String, t3 As String, t4 As StringPrivate Sub Command1_Click() If Text1 <> "" Then i = 0 Text2 = "" Timer1.Enabled = True Else MsgBox "请输入内容!", 48, "提示" End If End SubPrivate Sub Command2_Click() If Text2 <> "" Then X = 0 Text4 = "" Timer2.Enabled = True Else MsgBox "请输入内容!", 48, "提示" End If End SubPrivate Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 10 Timer2.Enabled = False Timer2.Interval = 10 End SubPrivate Sub Timer1_Timer() t1 = Text1.Text t2 = Text2.Text t3 = Text3.Text t4 = Text4.Text Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1)) + Len(Text1.Text) - i - 1 Text2.Text = Text3 + "," + Text2 i = i + 1 If i >= Len(Text1.Text) Then Timer1.Enabled = False End If End SubPrivate Sub Timer2_Timer() a = Split(Text2.Text, ",") Text3 = Chr(Val(a(X)) - X) Text4 = Text4 + Text3 X = X + 1 If X >= Len(Text1) Then Timer2.Enabled = False End If End Sub
Dim i As Integer Dim X As Integer Dim a() As String
Private Sub Command1_Click() If Text1 <> "" Then i = 0 Text2 = "" Timer1.Enabled = True Else MsgBox "请输入内容!", 48, "提示" End If End Sub
Private Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 10 End SubPrivate Sub Timer1_Timer() Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1) + 1) + Len(Text1.Text) - i - 1 Text2.Text = Text3 + "," + Text2 i = i + 1 If i >= Len(Text1.Text) Then Timer1.Enabled = False End If End Sub运行结果为:只能输入数字不能输入字母及符号,当输入9时出现49,应该是58的,恳求解决下为谢
好容易看懂了。你的意思实际上是,第 n 个字符,ASCII 码 + n。Option ExplicitDim i As Integer Dim X As Integer Dim a() As String Dim t1 As String, t2 As String, t3 As String, t4 As StringPrivate Sub Command1_Click() If Text1 <> "" Then i = 0 Text2 = "" Timer1.Enabled = True Else MsgBox "请输入内容!", 48, "提示" End If End SubPrivate Sub Command2_Click() If Text2 <> "" Then X = 0 Text4 = "" Timer2.Enabled = True Else MsgBox "请输入内容!", 48, "提示" End If End SubPrivate Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 10 Timer2.Enabled = False Timer2.Interval = 10 End SubPrivate Sub Timer1_Timer() t1 = Text1.Text t2 = Text2.Text t3 = Text3.Text t4 = Text4.Text Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1)) + Len(Text1.Text) - i Text2.Text = Text3 + "," + Text2 i = i + 1 If i >= Len(Text1.Text) Then Timer1.Enabled = False End If End SubPrivate Sub Timer2_Timer() a = Split(Text2.Text, ",") Text3 = Chr(Val(a(X)) - X - 1) Text4 = Text4 + Text3 X = X + 1 If X >= Len(Text1) Then Timer2.Enabled = False End If End Sub
Dim X As Integer
Dim a() As String
Dim t1 As String, t2 As String, t3 As String, t4 As StringPrivate Sub Command1_Click()
If Text1 <> "" Then
i = 0
Text2 = ""
Timer1.Enabled = True
Else
MsgBox "请输入内容!", 48, "提示"
End If
End SubPrivate Sub Command2_Click()
If Text2 <> "" Then
X = 0
Text4 = ""
Timer2.Enabled = True
Else
MsgBox "请输入内容!", 48, "提示"
End If
End SubPrivate Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 10
Timer2.Enabled = False
Timer2.Interval = 10
End SubPrivate Sub Timer1_Timer()
t1 = Text1.Text
t2 = Text2.Text
t3 = Text3.Text
t4 = Text4.Text
Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1)) + Len(Text1.Text) - i - 1
Text2.Text = Text3 + "," + Text2
i = i + 1
If i >= Len(Text1.Text) Then
Timer1.Enabled = False
End If
End SubPrivate Sub Timer2_Timer()
a = Split(Text2.Text, ",")
Text3 = Chr(Val(a(X)) - X)
Text4 = Text4 + Text3
X = X + 1
If X >= Len(Text1) Then
Timer2.Enabled = False
End If
End Sub
Dim X As Integer
Dim a() As String
Private Sub Command1_Click()
If Text1 <> "" Then
i = 0
Text2 = ""
Timer1.Enabled = True
Else
MsgBox "请输入内容!", 48, "提示"
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 10
End SubPrivate Sub Timer1_Timer()
Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1) + 1) + Len(Text1.Text) - i - 1
Text2.Text = Text3 + "," + Text2
i = i + 1
If i >= Len(Text1.Text) Then
Timer1.Enabled = False
End If
End Sub运行结果为:只能输入数字不能输入字母及符号,当输入9时出现49,应该是58的,恳求解决下为谢
Dim X As Integer
Dim a() As String
Dim t1 As String, t2 As String, t3 As String, t4 As StringPrivate Sub Command1_Click()
If Text1 <> "" Then
i = 0
Text2 = ""
Timer1.Enabled = True
Else
MsgBox "请输入内容!", 48, "提示"
End If
End SubPrivate Sub Command2_Click()
If Text2 <> "" Then
X = 0
Text4 = ""
Timer2.Enabled = True
Else
MsgBox "请输入内容!", 48, "提示"
End If
End SubPrivate Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 10
Timer2.Enabled = False
Timer2.Interval = 10
End SubPrivate Sub Timer1_Timer()
t1 = Text1.Text
t2 = Text2.Text
t3 = Text3.Text
t4 = Text4.Text
Text3.Text = Asc(Mid(Text1.Text, Len(Text1.Text) - i, 1)) + Len(Text1.Text) - i
Text2.Text = Text3 + "," + Text2
i = i + 1
If i >= Len(Text1.Text) Then
Timer1.Enabled = False
End If
End SubPrivate Sub Timer2_Timer()
a = Split(Text2.Text, ",")
Text3 = Chr(Val(a(X)) - X - 1)
Text4 = Text4 + Text3
X = X + 1
If X >= Len(Text1) Then
Timer2.Enabled = False
End If
End Sub