VB.NET Code not executing the way it should under Visual Studio

前端 未结 2 1922
忘了有多久
忘了有多久 2020-12-22 13:54

Hi I would like to ask a question guys I am doing an application in vb.net and my if else is acting weird instead of stating the correct caption in the label it shows the el

相关标签:
2条回答
  • 2020-12-22 14:12

    Access your project folder, head to the debug folder and delete everything there that can be deleted, ignore anything that can't be deleted because it's loaded in the memory. I don't see anything wrong with the code, if your code is acting funny, Visual Studio might have not replaced the one in the debug folder with the newly compiled one, which means the running app is the last one compiled before the error happened. This is a common bug in Visual Studio.

    0 讨论(0)
  • 2020-12-22 14:15

    I believe you intended to do this:

     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If TextBox1.Text = "What is your name?" Then
        Label1.Text = "Hi there kid! I will tell you later"
    Else
        Label1.Text = "Do you have anything you want to say other than that?"
    End If
    
    
     If TextBox1.Text = "Hi" Then
     Label1.Text = "Hi there also!"
     End If
    End Sub 
    
    0 讨论(0)
提交回复
热议问题