Results 1 to 12 of 12

Thread: [RESOLVED] Option Strict = ON - Late Binding Issue

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Resolved [RESOLVED] Option Strict = ON - Late Binding Issue

    I have turned Option Strict to ON.
    I am correcting all the conversion errors

    However, although I know having OS = On doesn't allow late binding....

    Then how do I perform an action on the main form from a 2nd modal form??

    Line Error:

    Code:
    frmMain.lstRTF.SelectedItem.Selected = True
    With OS = OFF, I don't have this issue

    Thanks in advance!
    Last edited by pixelink; Jul 12th, 2020 at 12:55 PM.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Re: Option Strict = ON - Late Binding Issue

    Well, to get around this.... I moved the sub into another module class
    And added "Option Strict Off" to the top.
    That fixed it.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Re: Option Strict = ON - Late Binding Issue

    Well... got one issue resolved, but now I have another

    I am getting a late binding error on this line

    Code:
    lstRTF.SelectedItem.Selected = True
    So what is with that. How do assign true values then??
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  4. #4
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    682

    Re: Option Strict = ON - Late Binding Issue

    Is lstRTF a listbox or a richtextbox? Neither have a SelectedItem.Selected property. What are you trying to do?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Re: Option Strict = ON - Late Binding Issue

    Quote Originally Posted by paulg4ije View Post
    Is lstRTF a listbox or a richtextbox? Neither have a SelectedItem.Selected property. What are you trying to do?
    It is a listbox.

    Hmm... the code doesn't flag as being wrong, but your right... there is no method like that.
    Not sure whats up. Compiles fine.
    Just trying to loop and find string in listbox

    And select that value in the listbox.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,394

    Re: Option Strict = ON - Late Binding Issue

    Just trying to loop and find string in listbox Then how is it selected? I worry for your previous company if you cant google its class. https://docs.microsoft.com/en-us/dot...ew=netcore-3.1

    look down and your have all the information you need. I'm sure you can find it.

  7. #7
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    682

    Re: Option Strict = ON - Late Binding Issue

    This will do the trick:

    Code:
            For i As Integer = 0 To ListBox1.Items.Count - 1
    
                If ListBox1.Items(i).ToString = "Fred" Then
                    ListBox1.SelectedIndex = i
                End If
    
            Next

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Re: Option Strict = ON - Late Binding Issue

    Quote Originally Posted by paulg4ije View Post
    This will do the trick:

    Code:
            For i As Integer = 0 To ListBox1.Items.Count - 1
    
                If ListBox1.Items(i).ToString = "Fred" Then
                    ListBox1.SelectedIndex = i
                End If
    
            Next
    Yeah, I already knew that.
    I use that for my main form.

    It was for some strange reason the incorrect code didn't cause design time error until I turned on Option Strict.

    So, I already fixed it just efore you posted.

    Thanks anyways
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Re: Option Strict = ON - Late Binding Issue

    Quote Originally Posted by ident View Post
    Just trying to loop and find string in listbox Then how is it selected? I worry for your previous company if you cant google its class. https://docs.microsoft.com/en-us/dot...ew=netcore-3.1

    look down and your have all the information you need. I'm sure you can find it.
    FYI... just so you know.
    I had a stroke last year and do not work at all.


    The app I am working on is for myself.

    A lot of apps today are made for people with accesibity issues.
    I am making an app to help instead of using a mouse.
    I can't use a mouse like I use to, neuropathy issues.

    So, forgive if my brain don't work right because i suffered brain damage from my stroke.

    Just thought you should know

    Last edited by pixelink; Jul 12th, 2020 at 02:51 PM.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  10. #10
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,394

    Re: [RESOLVED] Option Strict = ON - Late Binding Issue

    Yes, you have said multiple times. Don't think i am not sympathetic. I have spent nearly a year of the last 3 in and out of hospital, intensive care and isolation with avascular necrosis of femoral head, rhabdomyolysis, inflammatory arthritis, multiple coma, and had another seizure 2 weeks ago. I don't feel the need to advertise it in my signature. With all due respect your mentally able to find vbforums, open visual studio and ask a question. But yet cannot do any msdn searches?

    Your previous account technipixel has the same zero researching before said stroke. So there becomes a time when are you looking to play on heart strings with vbforum members writing your code for you.

    Not flaming just :/

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    185

    Re: [RESOLVED] Option Strict = ON - Late Binding Issue

    Quote Originally Posted by ident View Post
    Yes, you have said multiple times. Don't think i am not sympathetic. I have spent nearly a year of the last 3 in and out of hospital, intensive care and isolation with avascular necrosis of femoral head, rhabdomyolysis, inflammatory arthritis, multiple coma, and had another seizure 2 weeks ago. I don't feel the need to advertise it in my signature. With all due respect your mentally able to find vbforums, open visual studio and ask a question. But yet cannot do any msdn searches?

    Your previous account technipixel has the same zero researching before said stroke. So there becomes a time when are you looking to play on heart strings with vbforum members writing your code for you.

    Not flaming just :/

    Well that is totally uncalled for and untrue.

    I'll have you to know that I always do research on Google before ever posting on the Forum. The forum is the last place I try.

    You say your're are sympathetic, but you are totally mis-judging me.

    God Bless.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!

    My Website
    VSCOMM 2019 LAZARUS 2.08 Win10 16G RAM Nivida GForce RTX 2060

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,576

    Re: [RESOLVED] Option Strict = ON - Late Binding Issue

    When you turn Option Strict OFF, you are telling the compiler, "don't worry if this doesn't look right, when it runs it will make sense." So, it may well compile just fine, but that doesn't mean that it is. You are right to leave option Strict ON, and right to stop when a problem arises. Moving it into a module so that you can turn Option Strict OFF is a means of hiding an error from yourself. The error is still there, you just aren't seeing it. The error message you get would likely give you some information. It might even be kind of interesting, in this case. I expect it was seeing that the SelectedItem was an Object. What type, it wouldn't know, but by turning Option Strict OFF, you are telling it to assume that .Selected = True will make sense...once the code runs. It won't, though, it will just crash. It wouldn't crash if the object was something that had a .Selected property that was a Boolean, but it's a string, so it won't.

    @ident: I have a friend who had a stroke a couple years back. It's a different kind of thing. You have a good brain in a body that has caused you considerable trouble, of late. A stroke means that you lost some part of your brain. With my friend, he's pretty much the same, but there's something a bit different. Mostly, he can't walk so well, and it can be hard to understand him, I just feel like he either values things differently, or doesn't care very much. That's an injury that can have strange results.

    Still, there is some frustration on here about the lack of using MSDN. On the other hand, when a person doesn't understand something, it is usually that they DO have an understanding. They have a mental model of how things work, it's just that the model isn't right. Your brain is good at only one thing, as far as I can tell, which is recognizing patterns (that's the model). So, when you have the wrong model, your brain will try to fit whatever data you get into the model. It won't change the model to fit the data, it will first try VERY hard to make the data fit the model, including changing it to fit the model. This means that help like MSDN doesn't always get through simply because it doesn't fit the model. The key to programming is generally abandoning your mental model as soon as you get an error that doesn't make sense. That's what concerns me about moving the code to a module with Option Strict OFF. That's an attempt to fix the data that doesn't match the incorrect model, and that is certainly a frustrating question to try to answer. It's not the act of moving it that is objectionable, it's the reasoning behind it. If there is an error that you think shouldn't be there, then don't assume that the error is wrong, assume that your reason for thinking it shouldn't be there is wrong.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width