purana 发表于 2006-4-28 20:15:53

画直线问题

帮我看看这代码..只能画水平线...不能画任意角度的直线...请大家帮我修改一下... Option Explicit Dim MouseDowned As Boolean Dim oleX As Single Dim oleY As Single Dim NewX As Single Dim NewY As Single Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) MouseDowned = True oleX = X oleY = Y NewX = oleX NewY = oleY End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If MouseDowned Then If Button = vbLeftButton Then Me.Line (oleX, oleY)-(NewX, NewY) NewX = X: NewY = Y End If End If End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) MouseDowned = False End Sub

purana 发表于 2006-4-28 20:17:06

<p>倒..怎么代码成这样子..</p><p>Option Explicit</p><p>Dim MouseDowned As Boolean<br/>Dim oleX As Single<br/>Dim oleY As Single<br/>Dim NewX As Single<br/>Dim NewY As Single</p><p>Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br/>&nbsp;&nbsp;&nbsp; MouseDowned = True<br/>&nbsp;&nbsp;&nbsp; oleX = X<br/>&nbsp;&nbsp;&nbsp; oleY = Y<br/>&nbsp;&nbsp;&nbsp; NewX = oleX<br/>&nbsp;&nbsp;&nbsp; NewY = oleY<br/>End Sub</p><p>Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)<br/>&nbsp;&nbsp;&nbsp; If MouseDowned Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Button = vbLeftButton Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.Line (oleX, oleY)-(NewX, NewY)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NewX = X: NewY = Y<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; End If<br/>End Sub</p><p>Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)<br/>&nbsp;&nbsp;&nbsp; MouseDowned = False<br/>End Sub<br/></p>

purana 发表于 2006-4-29 20:19:16

嗯 ..之前搞错了..现在好了..
页: [1]
查看完整版本: 画直线问题