Solved

VB.NET Property Value

Posted on 2009-04-07
4
145 Views
Last Modified: 2012-05-06
I have to load some values from a sql table into my application and reuse them often. I have seen it before and was wondering how I would go about it. What I am looking to do is store my values and call them the following ways

for each sensor blah blah blah
     msgbox(sensors.field1)
     msgbox(sensors.field2)
     msgbox(sensors.field3)
next
0
Comment
Question by:jimseiwert
  • 2
  • 2
4 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24090362
You can create a class for that with the properties you need. Then you can create a new list(generics) of that class and use that way
0
 
LVL 2

Author Comment

by:jimseiwert
ID: 24090384
Can you show me an example please?
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24090701
Sure ... heres a generic example
Public Class Form1
 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim myList As New List(Of myInformation)
 

        Dim item1 As New myInformation

        item1.Field1 = "jpaulino"

        item1.Field2 = 1

        myList.Add(item1)
 

        Dim item2 As New myInformation With {.Field1 = "Another method", .Field2 = 2}

        myList.Add(item2)
 

        For Each item As myInformation In myList

            Debug.WriteLine(item.Field1 & " - " & item.Field2)

        Next
 

    End Sub
 

End Class
 
 

' The Class

Class myInformation
 

    Private m_Field1 As String

    Public Property Field1() As String

        Get

            Return m_Field1

        End Get

        Set(ByVal value As String)

            m_Field1 = value

        End Set

    End Property
 

    Private m_Field2 As Integer

    Public Property Field2() As Integer

        Get

            Return m_Field2

        End Get

        Set(ByVal value As Integer)

            m_Field2 = value

        End Set

    End Property
 

End Class

Open in new window

0
 
LVL 2

Author Closing Comment

by:jimseiwert
ID: 31567642
Just what I was looking for, Thanks !!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now