2017-09-08 78 views
0

第一種形式我有一個文本框,您可以在其中添加您的姓名,然後當您單擊下一個窗口時,第二種形式將彈出說我的名字是:您的名字。這很好,但是我怎麼能夠將稱爲OtherForm的第二個表單的名稱改爲我的名字,這樣當第二個表單彈出時,我的名字會出現在左上角而不是OtherForm?這是迄今爲止第一種和第二種形式的代碼。第二種形式在Visual Builder中不能正確加載?

主要形式代碼:

Public Class MainForm 

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles 
MyBase.Load 

End Sub 

Public Sub Label1_Click(sender As Object, e As EventArgs) Handles 
WindowName.TextChanged 




End Sub 

Public Sub WindowName_TextChanged(sender As Object, e As EventArgs) 

End Sub 

Public Sub OffButton_Click(sender As Object, e As EventArgs) Handles 
OffButton.Click 
    Me.Close() 


End Sub 

Public Sub NextButton_Click(sender As Object, e As EventArgs) Handles 
NextButton.Click 
    OtherForm.NameLabel.Text = WindowName.Text 
    OtherForm.Show() 
End Sub 
End Class 

第二種形式被稱爲OtherForm

Public Class OtherForm 

Public Sub CloseButton_Click(sender As Object, e As EventArgs) Handles 
CloseButton.Click 
    Me.Close() 
End Sub 

Public Sub OtherForm_Load(sender As Object, e As EventArgs) Handles 
MyBase.Load 

End Sub 

Public Sub NameLabel_Click(sender As Object, e As EventArgs) Handles 
NameLabel.Click 


End Sub 

Private Sub Label1_Click(sender As Object, e As EventArgs) Handles 
Label1.Click 

End Sub 
End Class 

回答

0

嘗試

OtherForm.Text = WindowName.Text 

設置窗體的標題。或者你可以設置文字爲任何你想要的。我不確定你的意思是「我的名字」還是你輸入的名字。

如果你的意思是「我的名字」,那麼你可以在表單屬性中輸入「文本」,而不是在代碼中。

相關問題