473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

split characters

Hello Everybody

Please help me to split the string, here is my code

HiddenMembers.Value += selectedItem.Value + ";" ;

I want to split the value and pass it to array. PLease help me to split HIddenMembers.value into individual value


Thanks
Jun 15 '07 #1
3 971
dip_developer
648 Expert 512MB
Hello Everybody

Please help me to split the string, here is my code

HiddenMembers.Value += selectedItem.Value + ";" ;

I want to split the value and pass it to array. PLease help me to split HIddenMembers.value into individual value


Thanks
Use the split () method of string

Split () returns a String array containing the substrings in this instance that are delimited by elements of a specified Char array.

here is the code in c# :

Expand|Select|Wrap|Line Numbers
  1.  
  2. // string seperated by colons ';'
  3.     string info = HiddenMembers.Value.ToString();
  4.  
  5.     string[ ] arInfo ;
  6.  
  7.     // define which character is seperating fields
  8.     char[ ] splitter = {';'};
  9.  
  10.     arInfo = info.Split(splitter);
  11.  
  12.     for(int x = 0; x < arInfo.Length; x++)
  13.     {
  14.         Response.Write(arInfo[x] + "<br>");
  15.     }
  16.  
  17.  
here is the code in VB :

Expand|Select|Wrap|Line Numbers
  1. Dim Info As StringInfo = HiddenMembers.Value.ToString()
  2. Dim arInfo As String() = Nothing
  3. arInfo = Info.Split(",")
  4. For x as Integer=0 To arInfo.Length-1 
  5. Response.Write(arInfo[x] & vbCrLf);
  6. Next 
Please check the code.....some modification may be needed....
Jun 15 '07 #2
Thank you very much, it works. I got the output that I want. My question is when I insert it to Database the output is

21 07580
21 15518
21 19558
21

it should be
21 07580
21 15518
21 19558

Here is my Code:

// string seperated by colons ';'
string info = HiddenMembers.Value.ToString();

string[] arInfo;

// define which character is seperating fields
char[] splitter = { ';' };

arInfo = info.Split(splitter);

for (int x = 0; x < arInfo.Length; x++)
{
//Response.Write(arInfo[x] + "<br>");

OracleTransaction myOracleTransactionMembers = con.BeginTransaction();

OracleCommand myOracleCommandMembers = con.CreateCommand();
myOracleCommandMembers.CommandText =
"INSERT INTO TEAM_MEMBERS (" +
" ITEM_NO,MEMBER_ID" +
") VALUES (" +
" '" + Label1.Text + "'," +
" '" + arInfo[x] + "'" +
")";

myOracleCommandMembers.ExecuteNonQuery();
myOracleTransactionMembers.Commit();


Thanks
Jun 15 '07 #3
Thank you very much, I got it.

instead of
for (int x = 0; x < arInfo.Length ; x++)

I used
for (int x = 0; x < arInfo.Length - 1; x++)


Thanks
Jun 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Salerno | last post by:
This is an example in the book I'm reading: string fullName = " Edward C Koop "; fullName = fullName.Trim(); string names = fullName.Split(' '); string firstName = names; //...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
3
by: David Pratt | last post by:
Hi. I am splitting a string on a non whitespace character. One or more whitespace characters can be returned as items in the list. I do not want the items in the list that are only whitespace (can...
4
by: Michele Petrazzo | last post by:
Hello ng, I don't understand why split (string split) doesn't work with the same method if I can't pass values or if I pass a whitespace value: >>> "".split() >>> "".split(" ") But into...
8
by: Wijaya Edward | last post by:
Hi all, I was trying to split a string that represent chinese characters below: ??? But why the split function here doesn't seem
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.