Assume that the user clicked a button asking to search for some information. You then create and display a TextBox for the user to enter the search criteria,and you also put a labelabove it describing the TextBox’s purpose
===============================================================
 Inherits System.Windows.Forms.Form
    Dim WithEvents btnSearch As New Button()
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim textBox1 As New TextBox()
        Dim label1 As New Label()
        ' specify some properties:
        label1.Text = "Enter your search term here..."
        label1.Location = New Point(50, 55) 'left/top
        label1.Size = New Size(125, 20) ' width/height
        label1.AutoSize = True
        label1.Name = "lable1"
        textBox1.Text = ""
        textBox1.Location = New Point(50, 70) 'left/top
        textBox1.Size = New Size(125, 20) ' width/height
        textBox1.Name = "TextBox1"
        btnSearch.Text = "Start Searching"
        btnSearch.Location = New Point(50, 95) 'left/top
        btnSearch.Size = New Size(125, 20) ' width/height
        btnSearch.Name = "btnSearch"
        ' Add them to the form’s controls collection.
        Controls.Add(textBox1)
        Controls.Add(label1)
        Controls.Add(btnSearch)
        'display all the current controls
        Dim i As Integer, n As Integer
        Dim s As String
        n = Controls.Count
        For i = 0 To n - 1
            s = Controls(i).Name
            Debug.Write(s)
            Debug.WriteLine("")
        Next
    End Sub
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        MsgBox("clicked")
    End Sub
 
No comments:
Post a Comment