InterviewSolution
| 1. |
Solve : Visual Basic - Trying to fix "End of statement expected"? |
|
Answer» I am trying to make a Visual Basic OS but I get 3 errors on Login.vb that are all "End of statement expected. Warning: 'Public Sub New()' in designer-generated type 'OSVB_0._5.Login' should CALL InitializeComponent method. //FIXED\\Quote from: simplyTechy100 on April 03, 2014, 08:36:45 PM O.O I am actually super confused for Visual Basic.. you are still using conditional compilation. remove the # from your Ifs and End Ifs. Quote from: simplyTechy100 on April 03, 2014, 08:55:00 PM Also, for the Login.vb, now I get 1 error and 1 warning.. I think you misunderstood. That segment was not supposed to be "fixed" code. I suggest you read through the Programmer's Guide on MSDN, which should guide you through the creation of some sample programs.Now you raised the error amount on the browser from 1 to 4...Quote from: simplyTechy100 on April 03, 2014, 09:12:11 PM Now you raised the error amount on the browser from 1 to 4... I didn't state anywhere that your use of conditional compilation was the only problem. Quote If Button1.Click() ThenWhat is this supposed to do? Are you simply guessing about what code you should write?Allow me to say something to the OP. BC programmer is well-qualified to assist you, but you're in making it hard. It appears that you have not really read the documentation for Visual Basic or else you skipped over something and tried to copy an example that was not appropriate. The key word that starts with the #is not really a program word, it is a directive for the compiler. Like BC said, it does not control actual program flow, it only qualifies how the compiler will treat your code. In other words, what you did is wrong. Unless you really wanted to do a compiler directive, and even in that case, you're still wrong. The compiler directive is something that has to be resolved at compile time, not at run-time. Normally it is something that would resolve immediately to a Boolean value or possibly an integer. It would be used either to select between TWO alternate forms of the code, or possibly from a list of other discreet options. Anyway, it does not control the run time code. Please use the notation that is given in the Visual Basic documentation for actual programs, and stop trying to use compiler directives. End of my rant, I am just trying to help. Pay attention to what BC programmer is telling you. He is the best you can find on this forum for Visual Basic. O.O I fixed the error. Well for the browser. Thanks Instructables! I got 1 error on the OS... still. Code: [Select]Public Class Login Public Sub New() InitializeComponent() If TextBox1.Text = "Administrator" Then TextBox2.Text = "AdminSuper32" End If If Button1.Click Then -It errors here Desktop.Show() End If If TextBox1.Text = "Administrator" And TextBox2.Text = "AdminSuper32" Then DeskAdmin.Show() End If End Sub End ClassQuote from: simplyTechy100 on April 04, 2014, 09:53:55 AM I got 1 error on the OS... still.Surely that error has a NAME and description and source line number.Quote 'Public Event Click(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.Line 7, Column 12 Login.vb You need to learn Visual Basic before trying to write software in it. What you are doing there to handle events like a button press is completely wrong - You don't use an if statement, you create methods (subroutines) that are bound to events such as a button being pressed and then when the button is pressed, that method is called. Also, name your controls something useful rather than TextBox1 or Button1 unless you want to get in a mess down the line.Quote from: simplyTechy100 on April 04, 2014, 09:53:55 AM Code: [Select]If Button1.Click Then -It errors hereAt least learn how to write a comment. |
|