English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Dim is_drawing As Integer

'Form event procedures:

Private Sub Form_Load()
is_drawing = False
End Sub

Private Sub Form_MouseDown(Button As_ Integer, Shift As Integer, X As Single_ , Y As Single)
is_drawing = True
CurrentX = X
CurrentY = Y
End Sub

Private Sub Form_MouseUp Button As_ Integer, Shift As Integer, X As Single_ , Y As Single)
is_drawing = False
End Sub

Private Sub Form_MouseMove Button As_ Integer, Shift As Integer, X As Single_ , Y As Single)
If is_drawing Then Line -(X, Y)
End Sub

2007-03-19 06:36:03 · 3 answers · asked by mombro 2 in Computers & Internet Programming & Design

the real problem i have is the mouse move event where i know i need to use draw line but not sure how to

2007-03-19 07:36:30 · update #1

3 answers

I'm not certain about the last sub statement (...Then Line - (x,y). You'll probably need to make "Line" a member of the system.drawing class, but the rest of this should get you started

Dim is_drawing As Integer

'Form event procedures:

Private Sub Form_Load()
is_drawing = False
End Sub

Private Sub Form_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
is_drawing = True
Dim CurrentX As Single = X
Dim CurrentY As Single = Y
End Sub

Private Sub Form_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
is_drawing = False
End Sub

Private Sub Form_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If is_drawing Then Line -(X, Y)
End Sub

hope that helps

EDIT

does this help?

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)
End Sub

2007-03-19 07:18:10 · answer #1 · answered by rod 6 · 0 0

I think this website ( http://msdn2.microsoft.com/en-us/library/2yscxd11(VS.80).aspx) should help you - it's the MSDN explanation of the difference between drawing lines in VB6 and VB2005.

I'm not entirely sure what currentX and currentY are for as you don't seem to use them but if you want to draw a line between the location the mouse button is pressed and the location it is released then you need to draw a line from CurrentX, CurrentY to X,Y in the MouseUp method.

If you want to use the mouseMove method to draw your line as the mouse is moved then first draw the line as above and then update currentX to equal X and currentyY to Y in the mouseMove method so that you keep updating the last position of the mouse.

Also the code given by the previous answerer looks pretty good but if you Dim currentX and currentY from within MouseDown then you won't be able to access them from any other method. Instead declare them at the top (with is_drawing). You should probably also add 'Option Explicit' as the first line as this will make the program throw errors if you forget to declare variables - seems annoying but it will show you any problems like the one just mentioned.

2007-03-19 08:32:20 · answer #2 · answered by Anonymous · 0 0

1) Open the VB2k5 environment.
2) Select File>Open
3) Navigate to your VB-6 app
4) Select it
5) Click the "Open" button

The code should automatically convert from VB98 to VB2k5

2007-03-19 10:14:21 · answer #3 · answered by Richard H 7 · 0 0

fedest.com, questions and answers