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 6919173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:57:22+00:00 2026-05-27T09:57:22+00:00

I have an array of 5 objects and also 5 textboxes. I am wanting

  • 0

I have an array of 5 objects and also 5 textboxes. I am wanting to check to see if the values in the corresponding textbox are valid for the type of object.

I have currently hard coded this, I parse out the object type and then use a tryparse statement depending on the object type.

Can I do this automatically? Can I detect the type and use a tryparse statement for that type. Maybe something like:

if objectarray(x).tryparse(textbox(x).text, nothing)

Canning

  • 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-27T09:57:23+00:00Added an answer on May 27, 2026 at 9:57 am

    The problem with this request is that TryParse is not specified at the object level.

    If you have a fixed set of data types that you are looking for, then you may be able to use extension methods to extend the Object type or you could add the test to your ObjectArray implementation.

    Update

    I was able to successfully implement an extension method on the Object class in C# using the following code:

    public static class MyExtensions
    {
        public static bool TryParse(this Object oObject, string s, out int result)
        {
            return System.Int32.TryParse(s, out result);
        }
    
    }
    

    and using it as:

            Object test = new object();
    
            int x;
    
            test.TryParse("1", out x);
    

    However, when I attempted to port this to Visual Basic, I discovered that you can extend a lot of things, but not the Object data type. This SO question has more specifics: VB.NET: impossible to use Extension method on System.Object instance

    So, you can extend Object in C# or, if the objects in your arrary are of a specific base type or implement a specific interface, you could extend that in order to implement this functionality.

    The alternative is to add this functionality directly to your object array class, then determine which tryparse to call based on the underlying data type.

    Within the objectarray class:

    Public Function TryParse(wIndex As Integer, s As String) As Boolean
    
        Dim oObject As Object
    
        oObject = Me.Item(wIndex)
    
        Select Case oObject.GetType.Name.ToLower
            Case "int32", "system.int32"
                Dim wTestInt As Integer
                Return Int32.TryParse(s, wTestInt)
    
                ' Etc...
    
        End Select
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of objects with various objects within to hold UI values.
I have an array of objects: Object = { 1 : { name :
I have an array of object names. These objects are HTML elements. I want
I have an array of stdClass objects that are very simple, every object looks
I have an array of type Person, which contains string objects: FirstName, LastName, login.
I have an array of objects which populate a UITableView . When a user
I have an Array of Objects that need the duplicates removed/filtered. I was going
I have an array of objects that have QTTime structs as attributes. The objects
I have an array of objects, and want the objects to be able to
I have an array of objects in MATLAB and I've called their constructors in

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.