Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.NET Property Value

Posted on 2009-04-07
4
Medium Priority
?
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

636 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