473,388 Members | 1,340 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,388 software developers and data experts.

Data Type

In VB6 I use this code:

Public Island() as MapPoint
Type MapPoint
GridEast as Single
GridNorth as Single
End Type

How do I do this in VB.NET?
Nov 22 '05 #1
4 1390
Hi Simon,

I think you'll like Structures in VB.NET. They are much cleverer than
those dumb VB6 Types.

Regards,
Fergus

<code>
Structure MapPoint
Public GridEast As Single
Public GridNorth As Single

'Optional
Public Sub New (ThisGridEast As Single, ThisGridNorth As Single)
GridEast = ThisGridEast
GridNorth = ThisGridNorth
End Sub

'Structures in VB.NET can be clever.
Public Sub GoNorth (Amount As Single)
GridNorth += Amount
End Sub

'Structures in VB.NET can be informative.
Public Overrides Function ToString As String
Return "(" & GridEast.ToString & ", " & GridNorth.ToString & ")"
End Function
End Structure

Public Island() As MapPoint

Public Sub TryMe
Dim WhereTheTreasureIs As New MapPoint (0, 100)
Dim IAmHere As MapPoint 'Defaults to (0, 0)

Dim S As String = vbCrLf
S &= IAmHere.ToString & vbCrLf
IAmHere.GoNorth (100)
S &= IAmHere.ToString & vbCrLf

S &= WhereTheTreasureIs.ToString & vbCrLf
S &= IAmHere.Equals (WhereTheTreasureIs).ToString & vbCrLf
S = S 'Breakpoint on me!
End Sub
</code>
Nov 22 '05 #2
Hi Simon,

I think you'll like Structures in VB.NET. They are much cleverer than
those dumb VB6 Types.

Regards,
Fergus

<code>
Structure MapPoint
Public GridEast As Single
Public GridNorth As Single

'Optional
Public Sub New (ThisGridEast As Single, ThisGridNorth As Single)
GridEast = ThisGridEast
GridNorth = ThisGridNorth
End Sub

'Structures in VB.NET can be clever.
Public Sub GoNorth (Amount As Single)
GridNorth += Amount
End Sub

'Structures in VB.NET can be informative.
Public Overrides Function ToString As String
Return "(" & GridEast.ToString & ", " & GridNorth.ToString & ")"
End Function
End Structure

Public Island() As MapPoint

Public Sub TryMe
Dim WhereTheTreasureIs As New MapPoint (0, 100)
Dim IAmHere As MapPoint 'Defaults to (0, 0)

Dim S As String = vbCrLf
S &= IAmHere.ToString & vbCrLf
IAmHere.GoNorth (100)
S &= IAmHere.ToString & vbCrLf

S &= WhereTheTreasureIs.ToString & vbCrLf
S &= IAmHere.Equals (WhereTheTreasureIs).ToString & vbCrLf
S = S 'Breakpoint on me!
End Sub
</code>
Nov 22 '05 #3
Use a Structure:

Structure MapPoint
Public GridEast as Single
Public GridNorth as Single
End Structure

By the way, there's a built in single based Point type
(System.Drawing.PointF)

--

Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com
"Simon Morris" <si**********@xtra.co.nz> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
In VB6 I use this code:

Public Island() as MapPoint
Type MapPoint
GridEast as Single
GridNorth as Single
End Type

How do I do this in VB.NET?

Nov 22 '05 #4
Use a Structure:

Structure MapPoint
Public GridEast as Single
Public GridNorth as Single
End Structure

By the way, there's a built in single based Point type
(System.Drawing.PointF)

--

Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com
"Simon Morris" <si**********@xtra.co.nz> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
In VB6 I use this code:

Public Island() as MapPoint
Type MapPoint
GridEast as Single
GridNorth as Single
End Type

How do I do this in VB.NET?

Nov 22 '05 #5

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

Similar topics

4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
4
by: Dan | last post by:
I'm trying to creat a data structure, that can be either a integer, double, string, or linked list. So I created the following, but don't know if it is the data structure itself causing problems,...
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
4
by: toby989 | last post by:
Hi All Anyone came across this problem before? I have an X<L file created by excel <xml id="model"> <root> <Row>
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
8
MMcCarthy
by: MMcCarthy | last post by:
Type MemSize RetVal of VarType() Declaration Char Conversion Boolean 2b vbBoolean(11) CBool() Byte 1b vbByte(17) ...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
10
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.