I'm writing a personal simple program that takes text from a textbox and searches it for numeric characters, and if the text has numeric characters, it then asks what HTML tags that should be placed before and after each number, or consecutive set of numbers.

So if it finds the number 7, it will wrap it with these tags: <span class="ref">7</span>
If it finds 875, it will wrap only the first and last number like so: <span class="ref">875</span>

I'm doing this a real stupid way, but I do not really know how to load or size an array on the fly, so what I have going on is this:

I set the array size according the the length property of the textbox. Then I analyze each character and add 2 spaces to the array when numbers are found so that room can be made for the before and after tags. After the array size is set (which works, but makes things slow, and when large amounts of text are entered it freezes), the program goes through the whole process again, loads the array with the before and after HTML tags in the proper places, empty the textbox, output the array.

I know this is probably laughable, but I've been playing around with it for about three months in spare time and I'm ready to ask for help, lol. ALL of this below is just to determine the size of the array. It pretty much does the same thing again to load the array, and I know there has to be a better way. This isn't something that needs immediate attention. I'm just learning. Thanks.


Code:
   'First if statment - validates input
        If txtString.Text = String.Empty Then
            MessageBox.Show("Text field cannot be empty", "Warning",
                     MessageBoxButtons.OK, MessageBoxIcon.Warning)
            txtString.Focus()
        Else
            'Assign the variables and retreive number tags
            strText = CStr(txtString.Text)

            'Assign textbox to variable
            strText = CStr(txtString.Text)
            intStringLength = strText.Length
            intArrayLength = intStringLength - 1


            'THIS WHOLE LOOP DOES NOTHING BUT DETERMINE THE ARRAY SIZE TO BE USED AND DECLARED AFTER DETERMINGING
            'HOW MANY EXTRA PLACES SHOULD BE MADE FOR BEFORE AND AFTER TAGS FOR EACH SET OF NUMBERS
            Do While intCount < intStringLength
                'Retrieves very first charactor from string
                strHolder = strText.Substring(intCount, 1)

                'Test characters for numbers
                If IsNumeric(strHolder) Then
                    blnContainsNumbers = True
                    intArrayLength += 1 'Make room for the before tag in the array
                    Do While IsNumeric(strHolder) = True And blnIsNumeric = True
                        intCount += 1 
                        blnIsNumeric = False

                        'If counter is less than string length, get another charactor
                        'This is to prevent an error when only one charactor is entered
                        If intCount < intStringLength Then
                            strHolder = strText.Substring(intCount, 1)
                            If IsNumeric(strHolder) Then
                                blnIsNumeric = True
                            End If
                        End If
                    Loop
                    intArrayLength += 1 'Make room for last tag in the array
                    intCount += 1

                Else
                    intCount += 1 'Go get another character if it's not the end of the string
                End If
            Loop
I took a couple classes in college on VB.NET and these are just the only string manipulation techniques that the book (which was split into two semesters) taught, but when large amounts of text are entered, the program hangs up and freezes. I've tested it every way under the sun, and it works perfectly (except for the slowness and eventually freezing if too much text is entered), except that the last character in the string cannot be numeric, but right now I'm not worried about that.