none
system generated compile error on form using checkbox

    Question

  • Hi
    I have a form with a checkbox object on and it is set to true in the properties.
    When i compile however there is an error thrown "BC30456 Windows is not a member of Textbox"
    The offending line in the form designer.vb is "Me.DSSCheck.CheckState = system.Windows.Forms.CheckState.Indeterminate". ( I have tried the three variations on this property without success).
    If i delete the line it is OK until I again change anything on the form.
    As this is an automatic system generated chunk of code I am at a loss to correct / avoid it.

    I also get a similar error when changing the colour of a Label.

    Thoughts?

    Monday, February 26, 2018 2:29 PM

Answers

  • SOLVED:

    The error was misleading. I had a textbox on the form called 'system' and although it was accepted as a valid name it caused several cascading problems.
    Renamed to 'systemname' and all is well.

    Thanks for your help folks.

    Rgards Charlie


    Charlie G4EST

    • Marked as answer by Chas_c Thursday, March 8, 2018 5:42 PM
    Thursday, March 8, 2018 5:41 PM

All replies

  • Hi

    Here is some code with a variety of state changes using CheckState that may help you sort out their use.

    ' Form1 weith CheckBox named DSSCheck with
    ' Checked property = True, and
    ' Button1, Button2, Button3 and Button4
    Option Strict On
    Option Explicit On
    Public Class Form1
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    	DSSCheck.CheckState = CheckState.Indeterminate
      End Sub
      Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    	DSSCheck.CheckState = CheckState.Checked
      End Sub
      Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    	DSSCheck.CheckState = CheckState.Unchecked
      End Sub
      Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    	Select Case DSSCheck.CheckState
    	  Case CheckState.Indeterminate
    		DSSCheck.CheckState = CheckState.Checked
    	  Case CheckState.Checked
    		DSSCheck.CheckState = CheckState.Unchecked
    	  Case Else
    		DSSCheck.CheckState = CheckState.Indeterminate
    	End Select
      End Sub
    End Class


    Regards Les, Livingston, Scotland

    Monday, February 26, 2018 2:52 PM
  • Do you have Option Strict On at the top of the file ? If not do so. I see TextBox mentioned and have to wonder if you are targeting the right control.

    This is perfectly acceptable code for a CheckBox.

    CheckBox1.CheckState = CheckState.Indeterminate


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, February 26, 2018 2:53 PM
    Moderator
  • My thought is that you have code with regard to a textbox that will not compile. As previously mentioned try setting option strict to on either at the top of the code window above any imports statements if any or in the applications properties for the entire app I think you can do it there. The initial error says TextBox and not CheckBox.

    Maybe you altered names of controls and are assigning properties to the wrong control. If so option strict on will hihglight various errors.


    La vida loca

    Monday, February 26, 2018 3:05 PM
  • Setting values is not the issue. The error is generated by the vb compile on a form creation. I have not attempted to change any values programatically.
    As this code is generated by the compiler internally, with a warning not to change it the fault seems to be within the automativally gernerated file.

    Thanks for responding in detail however.

    Monday, February 26, 2018 3:12 PM
  • I have no control over the file as it is system (compiler) generated. The 'header of this file is as below:

    ---------------------------------------------------------------------------------------------------------------------------

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
    Partial Class Form1
        Inherits System.Windows.Forms.Form


        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()>
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.

    --------------------------------------------------------------------------------------------------------------------

    ---- relevant auto generated code follows ---

     'DSSCheck
            '
            Me.DSSCheck.AutoSize = True
            Me.DSSCheck.Checked = True
            Me.DSSCheck.CheckState = system.Windows.Forms.CheckState.Checked - [error line]
            Me.DSSCheck.Location = New System.Drawing.Point(152, 177)
            Me.DSSCheck.Name = "DSSCheck"
            Me.DSSCheck.Size = New System.Drawing.Size(89, 17)
            Me.DSSCheck.TabIndex = 17
            Me.DSSCheck.Text = "DSS installed"
            Me.DSSCheck.UseVisualStyleBackColor = True

    --------------------------------------------------------------------------------------------------------------------

    This file ('Form1.Designer.vb") gets overwritten whenever I change any elements of the form.

    I have applied that in the compile settings but the error still reappears in the file when the compiler regenerates it.

    no idea or the 'textbox' reference in the error message as the error in the checkbox 'definition'. I am not targetting anything

    Thanks for the suggestion.

    Monday, February 26, 2018 3:33 PM
  • I tried it in the designer, no problem. 

            Me.CheckBox1.CheckState = System.Windows.Forms.CheckState.Indeterminate

    What you can try is make a copy of your project using File Explorer and then remove in your original project folder the bin and obj folders. 

    Start it again and those are again made new. 


    Success
    Cor

    Monday, February 26, 2018 3:34 PM
  • Quick reply:

    If i delete the offending line from the designer code it compiles and runs perfectly... If i delete the checkbox there is no problem.

    This is what id confusing me.

    I have just deleted the checkbox and it compiled without error. Reintroduced it and the same error arises

    Just tried setting checked to False in properties - NO ERROR

    Reset to TRUE - ERROR

    Solution leave as false and set true (default) in code

    AAAAARGH!

    Thanks again

    Monday, February 26, 2018 3:41 PM
  • Did you do what I wrote or are you here just asking for fun?


    Success
    Cor

    Monday, February 26, 2018 3:43 PM
  • Can you create a new project, place a checkbox on it, set the CheckState in the designer and see if it works or not?

    This would rule in/out external issue with conflicts to something else or a corruption some place (intentionally being vague).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, February 26, 2018 3:45 PM
    Moderator
  • Hi

    It seems that you have many other controls on the Form, based on the fact that your CheckBox TabIndex is 17.

    What are those controls? Are any of those also a CheckBox?


    Regards Les, Livingston, Scotland

    Monday, February 26, 2018 3:48 PM
  • 't seems that you are not allowed to do the standard solution.

    However, if my solution does not fit than do with your form in view. 

    Ctrl + Alt + t

    The document outline shows you than every control, probably you have some orphan controls. 


    Success
    Cor

    Monday, February 26, 2018 3:53 PM
  • Cor

    Posts crossed.
    After every successful build after I have updated the code i version the solution in the manner you suggest. This error is across solutions (several) over a month or so.

    Sarcasm doesn't help. i am not having fun.

    Monday, February 26, 2018 3:56 PM
  • Just did that - all OK.

    'CheckBox1
            '
            Me.CheckBox1.AutoSize = True
            Me.CheckBox1.Checked = True
            Me.CheckBox1.CheckState = System.Windows.Forms.CheckState.Checked
            Me.CheckBox1.Location = New System.Drawing.Point(93, 100)
            Me.CheckBox1.Name = "CheckBox1"
            Me.CheckBox1.Size = New System.Drawing.Size(81, 17)
            Me.CheckBox1.TabIndex = 0
            Me.CheckBox1.Text = "CheckBox1"
            Me.CheckBox1.UseVisualStyleBackColor = True

    no difference to the failing code.

    Monday, February 26, 2018 4:02 PM
  • Chas,

    My English is not good enough that I understand what you wrote. Is the problem gone or is it still there?



    Success
    Cor

    Monday, February 26, 2018 4:03 PM
  • Only one checkbox...

    8 buttons

    8 text boxes

    one volume slider object

    2 labels

    I have a workaround so will stick to that. Probably some weird combination of factors have caused this.
    incidentally project started in VS 2015 now running on VS 2017 as i hoped the new engine would cure the issue.

    • Marked as answer by Chas_c Monday, February 26, 2018 4:25 PM
    • Unmarked as answer by Chas_c Thursday, March 8, 2018 5:42 PM
    Monday, February 26, 2018 4:06 PM
  • The problem still exists if i have the checkbox 'checked' property set to 'true', but goes if set to 'false'.

    In the initialisation of the application i now programatically set it to true which achieves the same result.
    It is a 'fudge' but saves a manual removal of a line in the designer.vb code each time i ament the form.

    Thanks.

    I will mark as closed


    • Edited by Chas_c Monday, February 26, 2018 4:26 PM
    Monday, February 26, 2018 4:25 PM
  • PS:

    I transferred the form1 code to the new test project I used to check the isolated checkbox i created:

    It produced an error when checked property set to TRUE.

    Given up - the fix works so just living with it


    • Edited by Chas_c Monday, February 26, 2018 4:35 PM
    Monday, February 26, 2018 4:35 PM
  • SOLVED:

    The error was misleading. I had a textbox on the form called 'system' and although it was accepted as a valid name it caused several cascading problems.
    Renamed to 'systemname' and all is well.

    Thanks for your help folks.

    Rgards Charlie


    Charlie G4EST

    • Marked as answer by Chas_c Thursday, March 8, 2018 5:42 PM
    Thursday, March 8, 2018 5:41 PM
  • SOLVED:

    The error was misleading. I had a textbox on the form called 'system' and although it was accepted as a valid name it caused several cascading problems.
    Renamed to 'systemname' and all is well.

    Thanks for your help folks.

    Rgards Charlie


    Charlie G4EST

    LOL....That's why I mentioned the issue appeared to be with a TextBox since that is what the error pointed to. I remember using a namespace or class to name things before......I know the feeling. :(

    Hopefully this month will be much better for you now.

    Once I was testing VS 2015 Ultimate and using Dim Counter As Integer = 0 and the word Counter was causing major issues but I don't remember why now although I reported it...


    La vida loca

    Friday, March 9, 2018 3:03 AM
  • Yeah.

    The textbox reference was the clue (as you said)( but the error was so off the point as well as the error syntax being (seemingly) OK for other form objects really threw me off track.

    It would be an idea if these 'reserved words' had their own error message, perhaps even when namong an object, to prevent the situation arising in the first place,

    Cheers

    Charlie


    Charlie G4EST

    Friday, March 9, 2018 8:45 AM