In this article I will explain with an example, how to get TextBox value in Windows Forms (WinForms) application with C# and VB.Net
 
 

Form Design

The Form consists of following controls:
TextBox - For capturing Name.
Button - For displaying TextBox value.
Windows Forms: Get TextBox value using C# and VB.Net
 
 

Getting TextBox value on Button Click

Inside the btnSave_Click event handler, the TextBox value is displayed in MessageBox.
C#
private void btnSave_Click(object sender, EventArgs e)
{
    MessageBox.Show(txtName.Text);
}
 
VB.Net
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
    MessageBox.Show(txtName.Text)
End Sub
 
 

Screenshot

Windows Forms: Get TextBox value using C# and VB.Net
 
 

Downloads