Click here to Skip to main content
15,909,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi in form i have text box, my textbox values is like this A1 A2 A3 A4 A5

I want to take this value's one by one and assign to some string variable, how shall I do?


Thanks in Advance
Posted
Updated 30-Nov-10 21:09pm
v3

Thank yu for your question. Follow the bellow code.

VB
Dim strValue As String = "A1 A2 A3 A4 A5 F"
   Dim strTem As String
   strTem = String.Empty
   Dim i As Integer
   For i = 0 To strValue.Length - 1
       strTem += strValue.Substring(i, 1)
   Next



Thanks,
Mamun
 
Share this answer
 
Comments
Tarun.K.S 1-Dec-10 4:12am    
strValue should contain the value of TextBox.
C#
string l = String.Empty;
string[] arr = textbox1.text.Split(' ');
for (int i = 0; i <= arr.Length ;i++ )
{
    l = l + arr[i];
}


Apologies my answer is in C#, but you can use a similar concept in VB.Net.
 
Share this answer
 
v2
Comments
sameertm 1-Dec-10 3:29am    
thanks for your help but your coding showing some error like this 'Index was outside the bounds of the array'.
Abhinav S 1-Dec-10 3:38am    
1) This is C# code. You need to convert this to VB.Net.
2) I assumed here that you wanted to split your string on the space character.
3) Once you have your strings in the array you can use them as you need them.
sameertm 1-Dec-10 3:50am    
Dim l As String = [String].Empty
Dim arr As String() = textbox1.Text.Split(" "c)
For i As Integer = 0 To arr.Length
l = l & arr(i)
Next
well i converted, its return result what i expected, though when its its excute last value of string its showing error.'Index was outside the bounds of the array
Tarun.K.S 1-Dec-10 4:11am    
the for loop should be like this:
For i As Integer = 0 To arr.Length-1
l = l & arr(i)
Next i

You just have to put -1 after arr.Length
sameertm 1-Dec-10 5:01am    
thank u very much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900