0

I'll be going on a trip for the next 8 days with my mom and grandma. Leaving tomorrow. Will be back the evening of the 21st.

See everyone soon!

8
Contributors
15
Replies
74
Views
2 Years
Discussion Span
Last Post by diafol
Featured Replies
0

Family time is always time well spent. Enjoy!!!

PS. Say hello to your mum from me.

Edited by happygeek

1

hehe :)

Votes + Comments
If you ever meet my wife you can tell her that (at least occasionally) I DO pay attention.
0

Hey Reverend Jim,
Hope you and your family are having a good time. I have a question about some code you posted about 3 yrs back. For the most part it is doing what I need but I cannot figure out an added feature that I want to give it. If you would give me a shout back...Greg

1

Ha ha ha. That was defintely the right place to post that. Dani.s vacation. Your fan club is getting out of hand RJ!

Votes + Comments
It's a very small club ^_^
0

Reverend Jim,
I found the code you posted pertaining to creating textboxes dynamically on a form using VB.net. Once the program is executed I have it place 246 textboxes on the form. After they are created I then read a text file and load each box with the text in the file. All of this works fine. I also have the .tag property to increment by 1 think I would use it to step throught the boxes when I save the form. I placed a "save" button on the form so if I make any changes I can save it back to the file or another file of my choosing. When I click on the button it saves the last line 245 times. How do I step through all of the textboxes so I can write the text of each box to the text file? When loading the form I have set the .tag property to increment by 1 think I would use it to step through the boxes when I save the form. I just cannot figure out how to use the .tag property to allow me to step through the textboxes to save each line of text. In the example I have the basic code only.

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim FILE_NAME As String = "C:\Test.txt"

        If File.Exists(FILE_NAME) = True Then

            Dim objWriter As New StreamWriter(FILE_NAME)

            For z As Integer = 1 To 245

                objWriter.Write(newbox.Text & vbCrLf, False)

            Next
                objWriter.Close()
                MessageBox.Show("Text written to file")
        Else

                MessageBox.Show("File Does Not Exist")

        End If
    End Sub
0

Here is the snipet that creates the textboxes on the form. This works perfectly when it is included in my project.

  For i As Integer = 1 To 245 ' 5 indecates the number of textbox you want to create.

            'create a new textbox and set its properties
            newbox = New TextBox
            newbox.Tag = i
            newbox.Size = New Drawing.Size(725, 20)
            newbox.Location = New Point(10, 20 + 23 * (i - 1))
            newbox.Text = sInputLine
            sInputLine = srFileReader.ReadLine()
            newbox.Name = "TextBox" & i
            'connect it to a handler, save a reference to the array and add it to the form controls
            AddHandler newbox.TextChanged, AddressOf TextBox_TextChanged_1
            boxes(i) = newbox
            Me.Controls.Add(newbox)

        Next
0

I finally found the solution to my problem. It was much more simple than I was expecting. Here's what I used.

 For z As Integer = 1 To 245

                objWriter.Write(Me.Controls("Textbox" & (z)).Text & vbCrLf, False)

            Next

I guess I had a serious brain fart on this one.

Best Regards,

Edited by gmorris04

1

Get a room you two!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.