안녕하세요 저는 VB에서 응용 프로그램을하고있는 중 질문을하고 싶습니다. 그리고 다른 경우에는 레이블에 올바른 캡션을 표시하는 대신 이상한 동작을합니다. 이 : 여기 내 코드 이여 "? 당신이 아닌 다른 말하고 싶은 없나요"... 감사를 사전들에되는 대신 다른 문을 보여줍니다VB.NET 코드가 Visual Studio에서 실행되는 방식을 실행하지 않습니다.
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?"
If TextBox1.Text = "Hi" Then
Label1.Text = "Hi there also!"
Else
Label1.Text = "Do you have anything you want to say other than that?"
End If
End If
End Sub
'String.Compare' 또는'String.Equals'을 봐야합니다. 'If String.Equals (Label1.Text, "당신의 이름은 무엇입니까?") Then then .... http://stackoverflow.com/questions/900927/comparing-strings-in-vb – clcto
텍스트 상자에 입력 된 것과 공백이없고 문자열이 완전히 같고 대문자 나 소문자를 포함하는지 확인하십시오 소문자. –
@ chris_techno25 예 내 코드에서 볼 수있는 공백이 없습니다. 다른 텍스트와 정확히 동일합니다. 이유는 그것이 이상한 행동을하는 이유입니다. S – TheNewbie