Results 1 to 4 of 4

Thread: Create Textbox in run time problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108

    Create Textbox in run time problem

    i have create a textbox in the run time the code like below:

    TempCode_TextBox = New TextBox
    TempCode_TextBox.Location = New System.Drawing.Point(136, 16)
    TempCode_TextBox.Size = New System.Drawing.Size(100, 22)
    TempCode_TextBox.ReadOnly = True
    TempCode_TextBox.Name = "TempCode_TextBox" & TempX & ""
    TempCode_TextBox.Text = Me.code_TextBox.Text

    the TempX is for the looping number

    example like TempCode_TextBox1,TempCode_TextBox2,TempCode_TextBox3

    after i have create the 3 textbox how can i get all the value or data in the textbox that i create in the run time

    can i use the for loop statement to get all the value ??
    Last edited by ninjaX; Jun 27th, 2004 at 11:32 PM.

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    this?
    VB Code:
    1. Dim t(2) As TextBox
    2.    Sub wahehehe()
    3.       Dim i As Integer
    4.       Dim y As Integer = 20
    5.       For i = 0 To 2
    6.          t(i) = New TextBox()
    7.          t(i).Location = New Point(10, y)
    8.          t(i).ReadOnly = True
    9.          t(i).Name = "textbox" & i.ToString
    10.          t(i).Text = t(i).Name
    11.          Me.Controls.Add(t(i))
    12.          AddHandler t(i).KeyDown, AddressOf hahaha
    13.          y += 22
    14.       Next
    15.    End Sub
    16.  
    17.    Sub hahaha(ByVal sender As Object, ByVal e As KeyEventArgs)
    18.       Dim c As TextBox = sender
    19.       MessageBox.Show(c.Text)
    20.    End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108
    sorry

    after i create the text box in the run time, if i press the button save than it will help me to get the textbox value, it is possible to do that ???

  4. #4
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    this?
    VB Code:
    1. Dim t(2) As TextBox
    2.    Sub wahehehe()
    3.       Dim i As Integer
    4.       Dim y As Integer = 20
    5.       For i = 0 To 2
    6.          t(i) = New TextBox()
    7.          t(i).Location = New Point(10, y)
    8.          t(i).ReadOnly = True
    9.          t(i).Name = "textbox" & i.ToString
    10.          t(i).Text = t(i).Name
    11.          Me.Controls.Add(t(i))
    12.          y += 22
    13.       Next
    14.    End Sub
    15.  
    16.    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    17.       Dim i As Integer
    18.       Dim s As String
    19.       For i = 0 To UBound(t)
    20.          s += t(i).Text & Constants.vbCrLf
    21.       Next
    22.       MessageBox.Show(s)
    23.    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width