Wednesday 16 October 2013

Assigning TEXTBOX text to variables

Assigning TEXTBOX text to variables



            Instead of putting direct text into  variables, such as "Geetha" or "Rani",
we can get  text from a textbox and put that straight into your variables. We'll see
 how that's done now. 
  • Add a new textbox to our form.
  • With the TEXTBOX selected, locate the Name property in the                                               Properties area:

Change the NAME PROPERTY of TEXTBOX2 into 'txtLastName".



In this manner change the TEXTBOX1 NAME PROPERTY too.

Then add a BUTTON to the FORM.
Rename the button as shown in above.
Double click on button to write the below code.

        Dim FirstName As String
        Dim LastName As String
        Dim WholeName As String

        FirstName = txtFirstName.Text
        LastName = txtLastName.Text

        WholeName = FirstName & " " & LastName

        MsgBox(WholeName)


Then RUN the FORM.
Type any text in 2 TEXTBOXES.
Then click on Button..
It gives the RESULT in MESSAGE BOX.




<---- Previous page                                    Next Page ---->

VB.NET HOME PAGE

No comments:

Post a Comment