---
title: "Overwrite a string from the middle"  
description: "Overwrite a string from the middle"  
author: "Anonymous User"  
published: 2013-06-11  
updated: 2013-06-12  
canonical: https://www.mindstick.com/forum/1027/overwrite-a-string-from-the-middle  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 2 minutes  

---

# Overwrite a string from the middle

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs), \
How to create textboxes? I need to know if there is a way to [replace](https://yourviews.mindstick.com/view/81330/cow-antibody-research-in-usa-a-step-ahead-to-replace-plasma-therapy) the end of a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) with the new number.\
my line of [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) as following**\**

```
    While x <= tbnumberofitems    Dim x As Integer = 0 ' looop count '    Dim y As Integer = 1 ' name count'    Dim label1name As String = "label"    Dim textbox1name As String = "textbox"    While x <= tbnumberofitems        y = y + 1        If x = 0 Then y = 1        Convert.ToString(y)        Dim label1 As New Label        label1.Name = label1name & y
```

**\** 'Code to create [label](https://www.mindstick.com/articles/12835/print-label-tracking-how-do-these-features-make-auspost-woocommerce-plugin-better) box**\** **Dim textbox1 As New [TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview)** **textbox1.Name = textbox1name & y**\
'code to create text box\
**x = x + 1** **End While**\
This is what I currently have. What I need now is a way to make it where when the loop runs the next time, it changes the name to textbox2 and label2 on 3rd loop label 3 and textbox 3, etc. If that is not clear [enough](https://answers.mindstick.com/qa/48601/who-is-the-writer-of-the-one-life-is-not-enough) what I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to do is make it where the numberofitems, make it 5, creates 5 [labels](https://www.mindstick.com/forum/34568/badges-labels-page-headers) and 5 textboxes through the program.\
Any help on above is really appreciated.\

## Replies

### Reply by AVADHESH PATEL

Hi Ankita,\
Basicly you can figure out as following\
**For x as Integer = 1 to tbnumberofitems**\
'Code to create label\

```
    Dim lbl As New Label    lbl.Name = "label" & format(x)    lbl.Location = New Point(10, x*20)    Me.Controls.Add(lbl)
```

\
'Code to create textbox\

```
    Dim tb As New TextBox    tb.Name = "TextBox" & format(x)    tb.Location = New Point(100, x*20)    Me.Controls.Add(tb)
```

\


---

Original Source: https://www.mindstick.com/forum/1027/overwrite-a-string-from-the-middle

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
