array help

jdjd1118

Member
Joined
Nov 30, 2005
Messages
12
Programming Experience
Beginner
I have an array, for example:

*hi
*hi2
*hi3

This continues for an indefinate amount of time. I would like to remove the * and replace this with a number for each * in the array.

Thanks for any help!!
 
Sorry but it's quite unclear what really do you want to do ....
Can you restate your problem with more details?
I really am very sorry .. just want to help ...
 
The array cannot be "indefinite." It needs to be declared by a size. Then you can use a For-Next loop to modify the contents of each array element. For example, the following code will concatenate the index number before the rest of the text in each array element:


Dim hi(99) As String
For x As Integer = 0 To 99
hi(x) = x.ToString & hi(x)
Next
 
I have to agree with Daniel. You really haven't provided enough information for us to provide you with a solution that isn't just a guess. Please provide a full and clear indication of what you're trying to achieve, not just in the context of the code but also within the context of the application. What functionality is this supposed to implement? If we understand the what and the why, then we can provide the how.
 
yes .. that's definitely true ...

if you can provide with a more complete detail then it's gonna be much easier for us to help you and we can give the correct solution for the problem

:)
 
Basically, I want to take a list of text(from a textbox) such as:
*hi
*hi
*hi

and turn it into:
1hi
2hi
3hi
etc....

The list would be very long, the length will most likely be unknown to the user.
Thank you
 
VB.NET:
		Dim myList As New List(Of String)
		myList.AddRange(Me.TextBox1.Lines)

		For i As Integer = 0 To myList.Count - 1
			myList.Item(i) = myList.Item(i).Replace("*", i + 1)
		Next

		Me.TextBox1.Text = String.Join(Environment.NewLine, myList.ToArray)
 
I'd prefer to trim off the first char with string.Substring(1) and prepend the counter. Replace may affect other parts of the string. I'd also use a stringbuilder
 
Back
Top