| | |
Finding a specific character in a string
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 66
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: 452
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
Views: 391 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net box browser button c# checkbox commonfunctions complex connection dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dropdownlist dynamically edit editing expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis javascript list listbox login microsoft migration mono mouse mssql news numerical opera panelmasterpagebuttoncontrols parent problem project radio redirect registration relationaldatabases reportemail richtextbox rows save schoolproject search security select services session silverlight smartcard smoobjects software sql sql-server sqlserver2005 suse textbox theft tracking unauthorized validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





