VB6 to VB.Net - Using X1,X2,Y1,Y2 in .Net

Y

Y2K

I'm hoping someone can lend a hand. I've now been turned down four
times on Rentacoder because of various reasons... too difficult, wants
more $, needs complete rewrite, and coder never got bit acceptance.

The snippet below is a working example of a VB6 program. How would one

do the below in VB.Net?


Thanks for any help.



Code:
Option Explicit


Private nPicMidX     As Single
Private nPicMidY     As Single
Private nPicWidth    As Single
Private nPicHeight   As Single
Private clickX       As Single
Private clickY       As Single


Private Sub Form_Load()


With picImage(0)
nPicMidX = .Width / 2
nPicMidY = .Height / 2
nPicWidth = .Width
nPicHeight = .Height
End With 'picImage(0)


End Sub


Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)


Dim SelectedImg As Integer


FindImage X, Y


moveImage SelectedImg, 0, 0


End Sub


Private Sub moveImage(ImageIndex As Integer, _
ByVal DX As Single, _
ByVal DY As Single)


Dim newTop  As Single
Dim newLeft As Single


With picImage(ImageIndex)
newTop = .Top + DY
newLeft = .Left + DX
.Top = newTop
.Left = newLeft
End With 'picImage(ImageIndex)
moveImageLinks ImageIndex, newLeft + nPicMidX, newTop + nPicMidY


End Sub


Private Sub moveImageLinks(ByVal ImageIndex As Integer, _
ByVal newx As Single, _
ByVal newy As Single)


If ImageIndex = 0 Then
lineLink(0).X1 = newx
lineLink(0).Y1 = newy
Else
lineLink(0).X2 = newx
lineLink(0).Y2 = newy
End If


End Sub


Private Sub picImage_MouseDown(Index As Integer, _
Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)


clickX = X
clickY = Y


End Sub


Private Sub picImage_MouseMove(Index As Integer, _
Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)


If Button = 1 Then
moveImage Index, X - clickX, Y - clickY
End If


End Sub


Private Function FindImage(ByVal X As Single, _
ByVal Y As Single) As Integer


Dim myImg As Variant


For Each myImg In picImage
If myImg.Left < X Then
If ((myImg.Left + myImg.Width) > X) Then
If myImg.Top < Y Then
If ((myImg.Top + myImg.Height) > Y) Then
FindImage = myImg.Index
Exit Function
End If
End If
End If
End If
Next myImg
FindImage = 0


End Function
 
A

Armin Zingler

Y2K said:
I'm hoping someone can lend a hand. I've now been turned down four
times on Rentacoder because of various reasons... too difficult,
wants more $, needs complete rewrite, and coder never got bit
acceptance.

The snippet below is a working example of a VB6 program. How would
one

do the below in VB.Net?


Have the wizard migrate it to a VB.Net project.

See also:
http://msdn.microsoft.com/library/e...tionToVisualBasic70ForVisualBasicVeterans.asp

in particular:

http://msdn.microsoft.com/library/en-us/vbcon/html/vxconChangesToLineControlInVisualBasicNET.asp


Armin
 
Y

Y2K

I tried the built-in conversion, but it changes my line to a label.
I'll revisit that with 2005 (I used .Net 2003 previously). I'll also
check the MSDN link. Thanks.
 
K

Ken Halter

Y2K said:
I tried the built-in conversion, but it changes my line to a label.
I'll revisit that with 2005 (I used .Net 2003 previously). I'll also
check the MSDN link. Thanks.

Don't you wish the converter would >not< convert lines to labels? Geez. What
a pain. If I wanted a label, I would've used one, eh? <g> The code to
duplicate the functionality of a line control is what.... 5 or 6 lines?
Probably fewer than the converter uses to convert a line control to a label
in the first place. I can't imagine it taking a "team" of developers to say
"just convert them all to labels. they should be happy with that".
 
G

gene kelley

Don't you wish the converter would >not< convert lines to labels? Geez. What
a pain. If I wanted a label, I would've used one, eh? <g> The code to
duplicate the functionality of a line control is what.... 5 or 6 lines?
Probably fewer than the converter uses to convert a line control to a label
in the first place. I can't imagine it taking a "team" of developers to say
"just convert them all to labels. they should be happy with that".

Kind of how VB6 handles the situation when it can't find a control
that's been moved or deleted - it substitues a PictureBox as I recall.
If I wanted a PictureBox, I would have used one.

Regarding Lines:

Me.Label1.Location = New System.Drawing.Point(10,10)
Me.Label1.Size = New System.Drawing.Size(200, 1)

Above produces a 200 pixel x 1 pixel line, starting at 10,10 and whose
color is the the current backcolor of the label. Same can be done for
a vertical line. If you need a diaganal line, then sorry, you'll have
to use the Graphics.DrawLine method. That's the way it is. You can
either go with what's available, or, stick with what you have, or find
another alternative. That's just the way life is sometimes. This
constant, cynical nitpicking serves no constructive purpose IMO.

Gene


Gene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top