VB6.0简单实例!! 高分!!求大神解答!!求代码!!跪求!!

2024年11月14日 18:46
有2个网友回答
网友(1):

第一题:

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

网友(2):

第一题是让label1慢慢的移动到右下角,还是瞬间移动到右下角?