Results 1 to 8 of 8

Thread: [RESOLVED] [2005] Create Custom type

  1. #1

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Resolved [RESOLVED] [2005] Create Custom type

    Ok Here is my situation, I am writing a class that is used to convert between various GPS Coordinate Systems, To do this, the use can select a Datum which changes 2 values that are used in the calcualtions.
    ie
    Datum
    Name = "NAD83/WGS84 (Global)"
    a = 6378137
    b = 6353752.3142
    etc...
    What I have now is a structure that is defined as so
    VB Code:
    1. Public Structure Datum
    2.         Dim Name As String
    3.         Dim a As Double
    4.         Dim b As Double
    5.     End Structure

    what I am wondering is this, Is it possible to set up a custom type of sorts with 3 values, (name, a and b) so that I could do something like this

    VB Code:
    1. Public Property Datum() as DatumType
    2.         Get
    3.             Return DatumType.Name
    4.         End Get
    5.         Set(ByVal value As Double)
    6.             DatumType.Name = value
    7.         End Set
    8.     End Property

    Essentially what I want to happen is that when you go to set the property when using this class and you create a new instance, I want the Datum Property to give you a list of specific items that you can pick from that will then set the values of a anb b in the class

    VB Code:
    1. Dim gps As New ConvertGPS
    2. gps.Datum = 'have this show a predefined list of my datums to set the property

    I hope that I have been clear about this and thank you for any help
    Last edited by bmahler; Oct 25th, 2006 at 12:37 PM.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: [2005] Create Custom type

    Like this?
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim gps As New ConvertGPS
    3.         gps.Add(MyDatums.Wild_Bill_Test)
    4.         gps.Add(MyDatums.NAD83_WGS84_Global)
    5.         For Each d As Datum In gps
    6.             Console.WriteLine(d.Name)
    7.         Next
    8.     End Sub
    9.  
    10. Public Class Datum
    11.     Public Name As String
    12.     Public a As Double
    13.     Public b As Double
    14.     Public Sub New(ByVal newName As String, ByVal newA As Double, ByVal newB As Double)
    15.         Name = newName
    16.         a = newA
    17.         b = newB
    18.     End Sub
    19. End Class
    20. Public Enum MyDatums
    21.     NAD83_WGS84_Global = 0
    22.     Wild_Bill_Test = 1
    23. End Enum
    24. Public Class ConvertGPS
    25.     Inherits CollectionBase
    26.     'stores an array of all possible selections where the index is equal to the MyDatums enumerator
    27.     Private _dateNumList() As Datum = New Datum() _
    28.     {New Datum("NAD83/WGS84 (Global)", 6378137, 6353752.3142), New Datum("Wild Bill Test", 12, 12)}
    29.     Public Overridable Sub Add(ByVal name As MyDatums)
    30.         Me.List.Add(_dateNumList(name))
    31.     End Sub
    32.     Default Public Overridable ReadOnly Property Item(ByVal name As MyDatums) As Datum
    33.         Get
    34.             Return _dateNumList(name)
    35.         End Get
    36.     End Property
    37. End Class

  3. #3

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Create Custom type

    Hmmm, I used your example to play around a bit to get what I have now, but it still is not exactly what I am looking for, I am trying to make implementing this into the project a little easier, but I think with this I have actually made it a little more complicated. Here is what I have in my class so far. What I was hoping to acclomplish was to do away with the Datum Structure, however I need it to populate a combobox on the form. Is there a way to populate a combobox with all the items in my enum?

    oops, my code is too long so here is an attachment
    Attached Files Attached Files
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: [2005] Create Custom type

    You can use [Enum].GetNames() to get the text of the enums in an array and you can use that to fill the combo.

  5. #5

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Create Custom type

    Thanks
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  6. #6
    Addicted Member skea's Avatar
    Join Date
    Mar 2006
    Posts
    187

    Re: [2005] Create Custom type

    bmahler, some time back i developed a project to accomplish the direction you are heading! If you dont mind,It may be of help to you!
    Using:VS 2008 Team System :: SQL Server 2005 Standard Edition.
    ----------------------------------------------------------------

  7. #7

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [RESOLVED] [2005] Create Custom type

    You developed a project to convert GPS systems? or on using custom types?
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  8. #8
    Addicted Member skea's Avatar
    Join Date
    Mar 2006
    Posts
    187

    Re: [RESOLVED] [2005] Create Custom type

    The Former.
    Using:VS 2008 Team System :: SQL Server 2005 Standard Edition.
    ----------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width