Solved

VB.NET Property Value

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

13 Experts available now in Live!

Get 1:1 Help Now