Results 1 to 4 of 4

Thread: *Solved* How To Insert String Every Few Characters In Text

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    *Solved* How To Insert String Every Few Characters In Text

    Hello!
    I need to know how to insert a dash, for example, every 3 characters in string. (Then show it in a text box.) This is what I have right now but it doesn't do anything. What is wrong with this code?
    Thanks!
    ~NinjaNic
    Code:
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim YourText As String = TextBox1.Text
            For i As Int32 = YourText.Length To 0 Step -3
                YourText.Insert(i, "-")
            Next
            TextBox1.Text = YourText
        End Sub
    Last edited by NinjaNic; Apr 21st, 2015 at 09:20 PM.

Tags for this Thread

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