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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:26:39+00:00 2026-05-27T04:26:39+00:00

I have this problem with late binding: I am creating a grocery list application.

  • 0

I have this problem with late binding: I am creating a grocery list application. I have a class named Item which stores the name, price, quantity, and description of an item on the grocery list.

I have a module named ListCollection which defines a Collection of Item objects. I have created an Edit form which will automatically display the currently selected ListCollection item properties, but whenever I attempt to fill the text boxes, it tells me that Option Strict disallows late binding.

I COULD take the easy route and disable Option Strict, but I’d prefer to figure out what the problem is so I know for future reference.

I shall paste pertinent code here. (Late binding error is in EditItem.vb.)

Item.vb code:

' Member variables:
Private strName As String

' Constructor
Public Sub New()
    strName = ""

' Name property procedure
Public Property Name() As String
    Get
        Return strName
    End Get
    Set(ByVal value As String)
        strName = value
    End Set
End Property

ListCollection.vb code:

' Create public variables.
Public g_selectedItem As Integer ' Stores the currently selected collection item.

' Create a collection to hold the information for each entry.
Public listCollection As New Collection

' Create a function to simplify adding an item to the collection.
Public Sub AddName(ByVal name As Item)
    Try
        listCollection.Add(name, name.Name)
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

EditItem.vb code:

Private Sub EditItem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    ' Set the fields to the values of the currently selected ListCollection item.
    txtName.Text = ListCollection.listCollection(g_selectedItem).Name.Get ' THIS LINE HAS THE ERROR!

I have tried declaring a String variable and assigning the Item property to that, and I have also tried grabbing the value directly from the List item (not using the Get function), and neither of these made a difference.

How can I fix this problem?

  • 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-27T04:26:40+00:00Added an answer on May 27, 2026 at 4:26 am

    You must cast the item from “Object” to your type (“EditItem”).

    http://www.codeproject.com/KB/dotnet/CheatSheetCastingNET.aspx

    EDIT:

    Private Sub EditItem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        ' getting the selected item
        Dim selectedItem As Object = ListCollection.listCollection(g_selectedItem)
    
        ' casting the selected item to required type
        Dim editItem As EditItem = CType(selectedItem, EditItem)
    
        ' setting value to the textbox
        txtName.Text = editItem.Name
    

    I didn’t code anything in VB.NET for years, I hope it is all right.

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

Sidebar

Related Questions

I have this problem in my ASP.NET application where I'm seeing some of my
I have this problem I'm hoping someone knows the answer to. I have an
I have this problem where I open Visual Studio and the internal windows are
i have this problem to find a particular xml node l have post this
I have this problem I've been trying to tackle for a while. I have
i have this problem: ms-access could not delete and i found a potential solution
I have this problem that my sites uses alot of ajax and when a
I have this problem containing some inequations and requirement to minimize a value. After
I have this problem decomposing a relation schema into a set of schemas that
I have this problem where after a field (say Field3 in table MyTable) is

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.