请问一下这段代码有什么问题啊?

来源:百度知道 编辑:UC知道 时间:2024/09/28 17:56:22
Option Explicit
Dim LastX As Integer
Dim LastY As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Last X = X
Last Y = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Line (LastX, LastY)-(X, Y)
End If
If Button = 2 Then
Circle (X, Y), 50
End If
Last X = X
Last Y = Y
End Sub

你程序里上面定义的是LastX、LastY,结果后面引用的时候却成了Last X、Last Y,中间都多了个空格,明显前后不是一个变量嘛,能不出错嘛?

Option Explicit
Dim LastX As Integer
Dim LastY As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
LastX = X
LastY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Line (LastX, LastY)-(X, Y)
End If
If Button = 2 Then
Circle (X, Y), 50
End If
LastX = X
LastY = Y
End Sub
last和x中有个空格去掉就能运行!