| | |
Finding a specific character in a string
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 59
Reputation:
Solved Threads: 2
hello frndz..
i really need some urgent help on a simple problem.
im storing a string in a database, say its "1 2 3",these are actually the id's of something. in order to get the name from the ID, i need to seperate the id's from the string, that is 1,2,3. in a array may b. so i just want to know how i can achieve the same thing.
i tried this code, but its not working properly.
hope to get a help soon..
thanks..
i really need some urgent help on a simple problem.
im storing a string in a database, say its "1 2 3",these are actually the id's of something. in order to get the name from the ID, i need to seperate the id's from the string, that is 1,2,3. in a array may b. so i just want to know how i can achieve the same thing.
i tried this code, but its not working properly.
ASP.NET Syntax (Toggle Plain Text)
str = TextBox1.Text.Trim(); temp = str; for (int j = 0; j < str.Length; j++) { if (str.Contains(" ")) { i = str.IndexOf(" "); str=str.Substring(i, str.Length - (i+1)); Response.Write(" This is index "+i); Response.Write(" This is next string : "+str); } }
hope to get a help soon..
thanks..
0
#2 Oct 29th, 2009
•
•
•
•
hello frndz..
i really need some urgent help on a simple problem.
im storing a string in a database, say its "1 2 3",these are actually the id's of something. in order to get the name from the ID, i need to seperate the id's from the string, that is 1,2,3. in a array may b. so i just want to know how i can achieve the same thing.
i tried this code, but its not working properly.
ASP.NET Syntax (Toggle Plain Text)
str = TextBox1.Text.Trim(); temp = str; for (int j = 0; j < str.Length; j++) { if (str.Contains(" ")) { i = str.IndexOf(" "); str=str.Substring(i, str.Length - (i+1)); Response.Write(" This is index "+i); Response.Write(" This is next string : "+str); } }
hope to get a help soon..
thanks..
ASP.NET Syntax (Toggle Plain Text)
Dim NoList As String() Dim I As Byte NoList = Split(TextBox1.Text.Trim, ",") For I = 0 To NoList .Length - 1 Response.Write(" This is index " & CStr(i)) Response.Write(" This is next string : " & NoList(i)) Next I
Last edited by Kusno; Oct 29th, 2009 at 5:26 am. Reason: wrong
NEVER NEVER NEVER GIVE UP
•
•
Join Date: Jun 2009
Posts: 442
Reputation:
Solved Threads: 82
0
#3 Oct 29th, 2009
You can split a string into array of sub strings based on delimiter character such as space, comma.
ASP.NET Syntax (Toggle Plain Text)
string str = TextBox1.Text.Trim(); string[] temp = str.Split(' '); for (int j = 0; j < temp.Length; j++) { Response.Write(" This is index " + j.ToString()); Response.Write(" This is the string : " + temp[j]); } }
Last edited by Ramesh S; Oct 29th, 2009 at 5:41 am.
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
0
#4 Oct 29th, 2009
Try this
ASP.NET Syntax (Toggle Plain Text)
string str = TextBox1.Text.Trim(); for (int i = 0; i < str.Length; i++) { if (!str[i].Equals(Convert.ToChar(32))) { newList.Add(str[i]); } }
![]() |
Similar Threads
- Find character in string (C++)
- Which C++ string function returns nth character of the string? (C++)
- removing character string (C++)
- the middle character of a string (C++)
- Finding the first number char in a string (Java)
- Finding the Most Common Character in a String (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: Pop up window on condition in asp.net 2.0
- Next Thread: Retrieve field value from GridView to compute total
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview grid gridview homeedition hosting iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration news numerical objects order panelmasterpagebuttoncontrols radio ratings rotatepage save schoolproject search security serializesmo.table silverlight smartcard sql-server sqlserver2005 suse textbox tracking typeof unauthorized validation vb.net video videos view virtualdirectory vista visual-studio visualstudio web webarchitecture webdevelopemnt webservice xml youareanotmemberofthedebuggerusers





