473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3.  
  4. Private nPicMidX     As Single
  5. Private nPicMidY     As Single
  6. Private nPicWidth    As Single
  7. Private nPicHeight   As Single
  8. Private clickX       As Single
  9. Private clickY       As Single
  10.  
  11.  
  12. Private Sub Form_Load()
  13.  
  14.  
  15. With picImage(0)
  16. nPicMidX = .Width / 2
  17. nPicMidY = .Height / 2
  18. nPicWidth = .Width
  19. nPicHeight = .Height
  20. End With 'picImage(0)
  21.  
  22.  
  23. End Sub
  24.  
  25.  
  26. Private Sub Form_MouseDown(Button As Integer, _
  27. Shift As Integer, _
  28. X As Single, _
  29. Y As Single)
  30.  
  31.  
  32. Dim SelectedImg As Integer
  33.  
  34.  
  35. FindImage X, Y
  36.  
  37.  
  38. moveImage SelectedImg, 0, 0
  39.  
  40.  
  41. End Sub
  42.  
  43.  
  44. Private Sub moveImage(ImageIndex As Integer, _
  45. ByVal DX As Single, _
  46. ByVal DY As Single)
  47.  
  48.  
  49. Dim newTop  As Single
  50. Dim newLeft As Single
  51.  
  52.  
  53. With picImage(ImageIndex)
  54. newTop = .Top + DY
  55. newLeft = .Left + DX
  56. .Top = newTop
  57. .Left = newLeft
  58. End With 'picImage(ImageIndex)
  59. moveImageLinks ImageIndex, newLeft + nPicMidX, newTop + nPicMidY
  60.  
  61.  
  62. End Sub
  63.  
  64.  
  65. Private Sub moveImageLinks(ByVal ImageIndex As Integer, _
  66. ByVal newx As Single, _
  67. ByVal newy As Single)
  68.  
  69.  
  70. If ImageIndex = 0 Then
  71. lineLink(0).X1 = newx
  72. lineLink(0).Y1 = newy
  73. Else
  74. lineLink(0).X2 = newx
  75. lineLink(0).Y2 = newy
  76. End If
  77.  
  78.  
  79. End Sub
  80.  
  81.  
  82. Private Sub picImage_MouseDown(Index As Integer, _
  83. Button As Integer, _
  84. Shift As Integer, _
  85. X As Single, _
  86. Y As Single)
  87.  
  88.  
  89. clickX = X
  90. clickY = Y
  91.  
  92.  
  93. End Sub
  94.  
  95.  
  96. Private Sub picImage_MouseMove(Index As Integer, _
  97. Button As Integer, _
  98. Shift As Integer, _
  99. X As Single, _
  100. Y As Single)
  101.  
  102.  
  103. If Button = 1 Then
  104. moveImage Index, X - clickX, Y - clickY
  105. End If
  106.  
  107.  
  108. End Sub
  109.  
  110.  
  111. Private Function FindImage(ByVal X As Single, _
  112. ByVal Y As Single) As Integer
  113.  
  114.  
  115. Dim myImg As Variant
  116.  
  117.  
  118. For Each myImg In picImage
  119. If myImg.Left < X Then
  120. If ((myImg.Left + myImg.Width) > X) Then
  121. If myImg.Top < Y Then
  122. If ((myImg.Top + myImg.Height) > Y) Then
  123. FindImage = myImg.Index
  124. Exit Function
  125. End If
  126. End If
  127. End If
  128. End If
  129. Next myImg
  130. FindImage = 0
  131.  
  132.  
  133. End Function
  134.  
  135.  
  136.  
Mar 13 '06 #1
6 2557
"Y2K" <y2******@gmail.com> schrieb
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/en...icVeterans.asp

in particular:

http://msdn.microsoft.com/library/en...alBasicNET.asp
Armin

Mar 13 '06 #2
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.

Mar 13 '06 #3
"Y2K" <y2******@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
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".

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Mar 13 '06 #4
Y2K
HAHA.. True.

Mar 14 '06 #5
On Mon, 13 Mar 2006 15:27:36 -0800, "Ken Halter"
<Ken_Halter@Use_Sparingly_Hotmail.com> wrote:
"Y2K" <y2******@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googleg roups.com...
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".


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
Mar 14 '06 #6
Y2K
OK.. I guess this is a bit more difficult than I thought.

Y2k

Mar 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
3
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using...
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.