0

there is an error I have marked in the code below whether this is the cause of converting from c# to vb.net but if I create a new project vb.net with the textbox there is no problem whatsoever. if I run the original C# project then without error. Please recommend a solution. is there anything that needs to be modified in the designer?

Thanks this may be an event issue in the vb.net

'Code in C#
 private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 private void InitializeComponent()
        {
            Bunifu.UI.WinForms.BunifuTextBox.StateProperties stateProperties1 = new Bunifu.UI.WinForms.BunifuTextBox.StateProperties();
            Bunifu.UI.WinForms.BunifuTextBox.StateProperties stateProperties2 = new Bunifu.UI.WinForms.BunifuTextBox.StateProperties();
            Bunifu.UI.WinForms.BunifuTextBox.StateProperties stateProperties3 = new Bunifu.UI.WinForms.BunifuTextBox.StateProperties();
            Bunifu.UI.WinForms.BunifuTextBox.StateProperties stateProperties4 = new Bunifu.UI.WinForms.BunifuTextBox.StateProperties();
            this.BunifuTextBox1 = new Bunifu.UI.WinForms.BunifuTextBox();
            this.SuspendLayout();
 }
        private Bunifu.UI.WinForms.BunifuTextBox BunifuTextBox1;
Private components As System.ComponentModel.IContainer = Nothing
  Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing AndAlso (components IsNot Nothing) Then
                components.Dispose()
            End If
            MyBase.Dispose(disposing)
        End Sub
'error this line in bunifutextbox is ambiguous in the namespace bunifu.ui.winforms
 Private Sub InitializeComponent()
            Dim StateProperties1 As Bunifu.UI.WinForms.BunifuTextBox.StateProperties = New Bunifu.UI.WinForms.BunifuTextBox.StateProperties()
            Dim StateProperties2 As Bunifu.UI.WinForms.BunifuTextBox.StateProperties = New Bunifu.UI.WinForms.BunifuTextBox.StateProperties()
            Dim StateProperties3 As Bunifu.UI.WinForms.BunifuTextBox.StateProperties = New Bunifu.UI.WinForms.BunifuTextBox.StateProperties()
            Dim StateProperties4 As Bunifu.UI.WinForms.BunifuTextBox.StateProperties = New Bunifu.UI.WinForms.BunifuTextBox.StateProperties()
'The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified.  Please remove any changes and try opening the designer again.
            Me.BunifuTextBox1 = New Bunifu.UI.WinForms.BunifuTextBox()
            Me.SuspendLayout()
End Sub
'Error  BC30002 Type 'BunifuTextBox' is not defined.
        Friend WithEvents BunifuTextBox1 As BunifuTextBox
 
roy
  • 693
  • 2
  • 11
  • The code has to be after the InitializeComponent which is part of the form constructor. Error indicates the event is occurring before the constructor is completed. The event has to be registered at runtime. See : https://stackoverflow.com/questions/15795366/vb-net-add-class-event-at-runtime-to-an-interface-event – jdweng Sep 18 '22 at 13:52
  • @jdweng , thanks reply from you . the code is inside initializeComponent() you can see my code update – roy Sep 18 '22 at 14:25
  • Initialize component must be first. Also you cannot have "Friend" which registers the event during compile. See link The registering has to be done during execution when you add a control during execution. – jdweng Sep 18 '22 at 15:16
  • @jdweng , thanks for your reply. you mean the friend event it is from the original source of C# code so I convert according to the original from C# code – roy Sep 19 '22 at 02:20
  • The registering of the event in c# is probably being done inside the designer (executed during the InitializeCompent) and is not triggering the event. With Friend it looks like the event is getting triggered. Not sure why the differences, just know it is happening from the error. Often during the constructor events get triggered and you have to add code in the events when properties are null to do nothing. – jdweng Sep 19 '22 at 02:44
  • @jdweng , thanks for your reply. How does the code for null do nothing – roy Sep 19 '22 at 02:49
  • You have a compiler error and I was thinking runtime error. The error is in the designer code. The namespace in the designer code is not matching the module code. May be you are missing an include in the designer like include Bunifu.UI.WinForms. Check the include in the module and see if you have same in the designer code. – jdweng Sep 19 '22 at 03:16
  • @jdweng , I have checked the same with project c# – roy Sep 19 '22 at 03:48
  • Try FROM : Friend WithEvents BunifuTextBox1 As BunifuTextBox TO : Friend WithEvents BunifuTextBox1 As Bunifu.UI.WinForms.BunifuTextBox – jdweng Sep 19 '22 at 10:55
  • @jdweng , I've tried to keep the recommendations from you still error – roy Sep 19 '22 at 11:59
  • It looks like in every place that you have BunifuTextBox it needs to be changed to Bunifu.UI.WinForms.BunifuTextBox, All you posted code is good. So I suspect it is in the designer code where it need to be corrected. The designer is call from InitializeComponent() – jdweng Sep 19 '22 at 12:36

0 Answers0