VB6.0简单实例!! 高分!!求大神解答!!求代码!!跪求!!
第二题:点击command1,在文本框text1内生成5个10-50以内的随机数,点击command2,在文本框text2内将text1内的5个数从小到大排序
第三题:点击command1,在文本框text3内显示text1*text2的结果(面积问题),并且text1和text2能分别检验数据的合法性(是否输入的是数字,而不是字母及其他)
跪求VB大神解答三题,高分悬赏!!!!!!!!!!小神跪了!!
第一题是返回左上角,亲!! 展开
第一题:
Dim x As Long, y As Long
Private Sub Command1_Click()
Timer1.Interval = 300
End Sub
Private Sub Command2_Click()
Timer1.Interval = 0
End Sub
Private Sub Timer1_Timer()
x = x + 100
y = y + 100
Label1.Left = x
Label1.Top = y
If Label1.Top > Form1.Height Or Label1.Left > Form1.Width Then
x = 0
y = 0
Label1.Left = x
Label1.Top = y
End If
End Sub
第二题:
Dim a(1 To 5) As Integer
Private Sub Command1_Click()
Dim i As Integer
Dim s As String
Randomize
For i = 1 To 5
a(i) = CInt((50 - 10 + 1) * Rnd + 10)
s = s & CStr(a(i)) & " "
Next
Text1.Text = s
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer, t As Integer, s As String
For i = 1 To 4
For j = i + 1 To 5
If a(j) < a(i) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next
Next
For i = 1 To 5
s = s & CStr(a(i)) & " "
Next
Text2.Text = s
End Sub
第三题:
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 46 Then
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii <> 46 Then
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End If
End Sub
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub