formlesstree4 18 Report post Posted July 11, 2009 If you haven't read Lesson 1, please go back and do so. Lesson 1 - 1 will teach you how to use a string variable, and display it inside a little messagebox. Create a new Project (Control + N) in Visual Basic .NET, as a Windows Form and press OK. Once the project has been created, you're presented with the form. Double click the form. The following text should appear: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Above it, add the following line: Dim NewString As String This will create a string variable for the program to modify. Now, on the toolbar on the left hand side of the program, locate the TextBox, and create one on the form, by clicking the TextBox control, and then clicking on the form. Then, find the Button Control, and do the same thing you did to create the TextBox control. Now Double Click the button, and the following code should appear: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End Sub Inside this new code, add the following: NewString = TextBox1.text Messagebox.show(NewString) Let's break down the code: NewString = Textbox1.text This will set the variable we declared "NewString" equal to whatever is inside that TextBox. Messagebox.show(NewString) This will create a messagebox, that will show the variable inside it. So, this is how the entire code should look now: Public Class Form1 Dim NewString As String Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click NewString = TextBox1.Text MessageBox.Show(NewString) End Sub End Class Press the little green arrow at the top of the window (Or you can press F5) to start testing the program. Fill some text in the textbox, and press the button. If all worked well, a messagebox will appear showing the text inside a messagebox! Homework: Using your knowledge of variable types (Which you should have read back in Lesson 1), create a program that will display numbers from a textbox inside a message box. Share this post Link to post Share on other sites