翻译VB代码
Subcapt(iiAsInteger)S="asdfghjklqwertyuiopzxcvbnm1234567890"If(ii=5)ThenFori=0To4i2=I...
Sub capt(ii As Integer)
S = "asdfghjklqwertyuiopzxcvbnm1234567890"
If (ii = 5) Then
For i = 0 To 4
i2 = Int(Rnd(Len(S) - 1) * Len(S) + 1)
ss = Mid(S, i2, 1)
Label1(i).Caption = ss
Next i
Else
i3 = Int(Rnd(Len(S) - 1) * Len(S) + 1)
ss = Mid(S, i3, 1)
Label1(ii).Caption = ss
End If
End Sub
Private Sub Command1_Click()
If Command1.Caption = "停止" Then
Command1.Caption = "继续"
Timer2.Enabled = False
Else
Command1.Caption = "停止"
Timer2.Enabled = True
End If
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_Load()
capt (5)
End Sub
Private Sub Timer2_Timer()
For i = 0 To 4
Label1(i).Top = Label1(i).Top + 100
If (Label1(i).Top >= Form1.Height) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
End If
Next i
End Sub
---------------------------------
高手来下哈... 展开
S = "asdfghjklqwertyuiopzxcvbnm1234567890"
If (ii = 5) Then
For i = 0 To 4
i2 = Int(Rnd(Len(S) - 1) * Len(S) + 1)
ss = Mid(S, i2, 1)
Label1(i).Caption = ss
Next i
Else
i3 = Int(Rnd(Len(S) - 1) * Len(S) + 1)
ss = Mid(S, i3, 1)
Label1(ii).Caption = ss
End If
End Sub
Private Sub Command1_Click()
If Command1.Caption = "停止" Then
Command1.Caption = "继续"
Timer2.Enabled = False
Else
Command1.Caption = "停止"
Timer2.Enabled = True
End If
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_Load()
capt (5)
End Sub
Private Sub Timer2_Timer()
For i = 0 To 4
Label1(i).Top = Label1(i).Top + 100
If (Label1(i).Top >= Form1.Height) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
End If
Next i
End Sub
---------------------------------
高手来下哈... 展开
3个回答
2009-02-20
展开全部
Sub capt(ii As Integer) '自定义过程
S = "asdfghjklqwertyuiopzxcvbnm1234567890" '变量s值
If (ii = 5) Then '如果ii=5 则执行for循环
For i = 0 To 4
i2 = Int(Rnd(Len(S) - 1) * Len(S) + 1) '1到变量s字符长度区间随机选取一个数
ss = Mid(S, i2, 1) '从s里截取位置(随机数i2)的字符赋值给ss
Label1(i).Caption = ss 'ss值赋值给 标签
Next i
Else
i3 = Int(Rnd(Len(S) - 1) * Len(S) + 1) '同上
ss = Mid(S, i3, 1)
Label1(ii).Caption = ss
End If
End Sub
Private Sub Command1_Click()
If Command1.Caption = "停止" Then
Command1.Caption = "继续"
Timer2.Enabled = False
Else
Command1.Caption = "停止"
Timer2.Enabled = True
End If
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then 'lcase转换大小写
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i) '调用过程capt
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_Load()
capt (5)
End Sub
Private Sub Timer2_Timer()
For i = 0 To 4
Label1(i).Top = Label1(i).Top + 100 '标签上边距+100
If (Label1(i).Top >= Form1.Height) Then '如果超过窗体高度
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
End If
Next i
End Sub
其他都很简单。应该不会不懂吧。
S = "asdfghjklqwertyuiopzxcvbnm1234567890" '变量s值
If (ii = 5) Then '如果ii=5 则执行for循环
For i = 0 To 4
i2 = Int(Rnd(Len(S) - 1) * Len(S) + 1) '1到变量s字符长度区间随机选取一个数
ss = Mid(S, i2, 1) '从s里截取位置(随机数i2)的字符赋值给ss
Label1(i).Caption = ss 'ss值赋值给 标签
Next i
Else
i3 = Int(Rnd(Len(S) - 1) * Len(S) + 1) '同上
ss = Mid(S, i3, 1)
Label1(ii).Caption = ss
End If
End Sub
Private Sub Command1_Click()
If Command1.Caption = "停止" Then
Command1.Caption = "继续"
Timer2.Enabled = False
Else
Command1.Caption = "停止"
Timer2.Enabled = True
End If
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then 'lcase转换大小写
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i) '调用过程capt
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
For i = 0 To 4
If LCase(Trim(Label1(i).Caption)) = LCase(Chr(KeyCode)) Then
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
Label2.Caption = Int(Label2.Caption) + 1
End If
Next i
End Sub
Private Sub Form_Load()
capt (5)
End Sub
Private Sub Timer2_Timer()
For i = 0 To 4
Label1(i).Top = Label1(i).Top + 100 '标签上边距+100
If (Label1(i).Top >= Form1.Height) Then '如果超过窗体高度
j = Int(Rnd(Form1.Width) * Form1.Width + 1)
Label1(i).Top = 0
Label1(i).Width = j
capt (i)
End If
Next i
End Sub
其他都很简单。应该不会不懂吧。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询