Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7408747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:58:03+00:00 2026-05-29T05:58:03+00:00

Okey, here is my problem, im calling a bunch of different propertys named K0

  • 0

Okey, here is my problem, im calling a bunch of different propertys named K0 to K6, im using a string to check which one i need to access, this is damn messy, how can i do it in a more clean way? Im convinced that strings are not the way to go so please give me a comment to get in the right direction.

Dim tempAntDec As Integer

Select Case wd.MClass 
                    Case "K0" 
                        tempAntDec = wd.allMeasUnc.K0.antDec 
                    Case "K1" 
                        tempAntDec = wd.allMeasUnc.K1.antDec 
                    Case "K2" 
                        tempAntDec = wd.allMeasUnc.K2.antDec 
                    Case "K3" 
                        tempAntDec = wd.allMeasUnc.K3.antDec 
                    Case "K4" 
                        tempAntDec = wd.allMeasUnc.K4.antDec 
                    Case "K4-5" 
                        tempAntDec = wd.allMeasUnc.K4_5.antDec 
                    Case "K5" 
                        tempAntDec = wd.allMeasUnc.K5.antDec 
                    Case "K5-6" 
                        tempAntDec = wd.allMeasUnc.K5_6.antDec 
                    Case "K6" 
                        tempAntDec = wd.allMeasUnc.K6.antDec 
                End Select  

I would like to call this in some other way like, this.. or dont know but i feel like there is a better way to handle this?

tempAntDec = wd.allMeasUnc.KValue.antDec
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:58:04+00:00Added an answer on May 29, 2026 at 5:58 am

    You might try the VB.NET CallByName Function.

    If that doesn’t work then give some simple reflection a try. Here is a link to a simple reflection tutorial. It’s in C# but should be fairly easy to convert to VB.NET. Here’s the untested code for doing it using reflection:

    ' Get the K-object reflectively.
    Dim mytype As Type = wd.allMeasUnc.GetType()
    Dim prop as PropertyInfo = mytype.GetProperty(wd.MClass) ' From the System.Reflection namespace
    Dim Kobject as Object = prop.GetValue(wd.allMeasUnc, Nothing)
    
    ' Get the antDec property of the K-object reflectively.
    mytype = Kobject.GetType()
    prop = mytype.GetProperty("antDec")
    tempAntDec = prop.GetValue(Kobject, Nothing)
    

    Depending on your compiler settings you may need to use DirectCast to convert the last line into an integer (because GetValue returns it as a plain Object). Something like “tempAntDec = DirectCast(prop.GetValue(Kobject, Nothing), Integer)” would probably work if needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okey, I have two strings containing numbers like shown here using debugger: String 1
okey so here is my structure. one.php two.php three.php one.php includes both two.php and
Okey, this is my problem. I have one service class where Ive managed to
How to access an object using a variable as key. Here is my code
Okey this is really strange. I have this script which basically downloads bunch of
I'm trying to download multiple files using IntentService. The IntentService donwloads them okey as
Okey, here it goes. I have a block of code that repeats it self
Okey here is this Very good jquery slider. http://srobbin.com/jquery-plugins/pageslide and what i have done
Okey. Here's what I want to do: I have a windows application that sorts
i want to access the bytes of an object in C# okey for example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.