Solved

VB.NET Property Value

Posted on 2009-04-07
4
151 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

763 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