How to use text boxes to input & display data in VB6 ?
To use the text box, we will first have to create a "Form". When we turn on Visual Basic, a wizard appears in which we have to select "Standard Exe". After clicking on "Standard Exe" a form will open.
In this form we will add text box and button and start coding.
In this example we will take 3 buttons, 2 test boxes and 1 label. The names of all of them have to be added in the order given below.
For Text box : use name Text1 & text2
For Button : use Command1,Command3 & Command3
This will be the default ones. If we want change, we can do.
Now Double Click any of the button & paste the code given below. Now Run the project by clicking start buton.
Here caption name of 3 buttons has been changed.
When we click on command1 it will send data to the text box1: "My Name". Command2 will clear the textbox1 & command3 will take data from text1 & display the same data to textbox2 by adding "Hello" before it.
Code:
Private Sub Command1_Click()
Text1.Text = "My Name"
End Sub
Private Sub Command2_Click()
Text1.Text = ""
End Sub
Private Sub Command3_Click()
Text2.Text = "Hello " & Text1.Text
End Sub