| | |
Finding a specific character in a string
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 56
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 28 Days Ago
•
•
•
•
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; 28 Days Ago at 5:26 am. Reason: wrong
NEVER NEVER NEVER GIVE UP
•
•
Join Date: Jun 2009
Posts: 432
Reputation:
Solved Threads: 82
0
#3 28 Days Ago
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; 28 Days Ago at 5:41 am.
•
•
Join Date: Dec 2007
Posts: 205
Reputation:
Solved Threads: 11
0
#4 28 Days Ago
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 appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol expose findcontrol flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml youareanotmemberofthedebuggerusers





