[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vb.net list of variables or constants

Posted on 2007-07-25
2
Medium Priority
?
1,470 Views
Last Modified: 2013-11-07
vb.net list of variables or constants in a form

here is a list of const declarations in a form

    Public Const toSquareInch As Decimal = 1.0
    Public Const toSquareFeet As Decimal = 0.006944444444
    Public Const toSquareYard As Decimal = 0.000771604938

I want to retrive a list of these, i.e. do something that will  return the followin (the names not the contents)

     toSquareInch
     toSquareFeet
    toSquareYard
0
Comment
Question by:APLIT
2 Comments
 
LVL 5

Accepted Solution

by:
Bart-De-Bal earned 2000 total points
ID: 19564397
This gives the result that you need:

        For Each fi As System.Reflection.FieldInfo In CType(Me, Object).GetType().GetFields()
            MsgBox(fi.Name)
        Next
0
 
LVL 1

Expert Comment

by:kiran_ramisetti
ID: 19564801
to get the value of constant variable values write like this :

       For Each fi As System.Reflection.FieldInfo In CType(Me, Object).GetType().GetFields()
            MsgBox(fi.GetValue(fi))
        Next
Result is: 1
                0.006944444444
                0.000771604938

or if you want get the name of the constatnt variables you can writte like this :
        For Each fi As System.Reflection.FieldInfo In CType(Me, Object).GetType().GetFields()
            MsgBox(fi.Name)
        Next

Result is : toSquareInch
                 toSquareFeet
                 toSquareYard
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

873 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