翻译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

---------------------------------

高手来下哈...
展开
 我来答
匿名用户
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

其他都很简单。应该不会不懂吧。
好人1号
2009-02-20 · TA获得超过650个赞
知道小有建树答主
回答量:605
采纳率:0%
帮助的人:270万
展开全部
??????????????????????????
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
英博双语灬鹏
2009-02-20
知道答主
回答量:43
采纳率:0%
帮助的人:0
展开全部
漂亮
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式