473,396 Members | 2,129 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,396 software developers and data experts.

How to remove last comma

Hi,I am new to .net.
As per ur guidance I tried myString = myString.SubString(0,myString.Length-1);
I also used str.lastindexof n str.remove,but by using this I m gettin string as ' (B193 '' H13 '' H14 ' ) instead of (' B193 ',' H13 ',' H14' ).My original string is
(' B193 ',' H13 ',' H14 ', )I want to remove last comma.My code is ---

Dim s1, strpid As String
Dim arr(), arr2()
Dim i As Integer
s1 = Request("PatientIDs")
arr = Split(s1, ":")
For i = 0 To UBound(arr)
arr2 = Split(arr(i), ">")
strpid = ("'" & arr2(0) & "'" & ",")
Response.Write(strpid)
Next

Plz reply.
Jan 12 '08 #1
13 1878
CyberSoftHari
487 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. myString = myString.SubString(0,myString.Length-1);
This should work. What is the output you are getting?
Jan 12 '08 #2
Expand|Select|Wrap|Line Numbers
  1. myString = myString.SubString(0,myString.Length-1);
This should work. What is the output you are getting?
I am getting --(' B193 '' H13 '' H14 ' ).this is removing all commas.I want
(' B193 ',' H13 ',' H14 ' )
Jan 12 '08 #3
CyberSoftHari
487 Expert 256MB
can you post exact code part?(Check where you are using.)
Jan 12 '08 #4
can you post exact code part?(Check where you are using.)
I am sending whole code
Dim s1, strpid As String
Dim arr(), arr2()
Dim i, j As Integer
s1 = Request("PatientIDs")
arr = Split(s1, ":")
For i = 0 To UBound(arr)
arr2 = Split(arr(i), ">")
strpid = Trim("'" & arr2(0) & "'" & ",")
j = strpid.LastIndexOf(",")
strpid = strpid.Remove(j, 1)
Response.Write(strpid)
Next
'Query = "select patient_id,patient_name,study_instance_UID from studies where patient_id in " + Trim(strpid) + " "
'show_selected(Query)

I am writing on page load.
Jan 12 '08 #5
CyberSoftHari
487 Expert 256MB
But there is no
Expand|Select|Wrap|Line Numbers
  1. myString = myString.SubString(0,myString.Length-1);
I mean, No
Expand|Select|Wrap|Line Numbers
  1. Substring 
keyword
Jan 12 '08 #6
But there is no
Expand|Select|Wrap|Line Numbers
  1. myString = myString.SubString(0,myString.Length-1);
I mean, No
Expand|Select|Wrap|Line Numbers
  1. Substring 
keyword
yes,I m getting str.substring
But it is removing all commas,while I want to remove onle last one.
Jan 12 '08 #7
But there is no
Expand|Select|Wrap|Line Numbers
  1. myString = myString.SubString(0,myString.Length-1);
I mean, No
Expand|Select|Wrap|Line Numbers
  1. Substring 
keyword
I m sorry,First time I did'nt got ur questn.So replying second time.


Dim s1, strpid As String
Dim arr(), arr2()
Dim i, j As Integer
s1 = Request("PatientIDs")
arr = Split(s1, ":")
For i = 0 To UBound(arr)
arr2 = Split(arr(i), ">")
strpid = Trim("'" & arr2(0) & "'" & ",")
strpid = strpid.Substring(0, strpid.Length - 1)
strpid = strpid.Trim(arr2(0))
Response.Write(strpid)
Next

Actually I am trying number of methods.Writing-deleting code again n again.
Jan 12 '08 #8
CyberSoftHari
487 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. str = str.SubString(0,str.Length-1);
  2. MessageBox.Show(str);
run this code and see the popup message.

Note: Write this code outside for loop.
Jan 12 '08 #9
Expand|Select|Wrap|Line Numbers
  1. str = str.SubString(0,str.Length-1);
  2. MessageBox.Show(str);
run this code and see the popup message.

Note: Write this code outside for loop.
I am getting selected id one by one.I mean If I select three row it is giving id like
('B193') on clinking ok it gives second id,then third.that is in quotation mark.
Jan 12 '08 #10
CyberSoftHari
487 Expert 256MB
This seems you never got the concept.
Where you receiving the value “' B193 ',' H13 ',' H14 ',”?
Note: You have to try (Giving the solution to a homework will be a spam here) I pointed that is exactly correct but the thing is where you are applying!) try Survana you can do?... Come..on).
Jan 12 '08 #11
dip_developer
648 Expert 512MB
Hi,I am new to .net.
As per ur guidance I tried myString = myString.SubString(0,myString.Length-1);
I also used str.lastindexof n str.remove,but by using this I m gettin string as ' (B193 '' H13 '' H14 ' ) instead of (' B193 ',' H13 ',' H14' ).My original string is
(' B193 ',' H13 ',' H14 ', )I want to remove last comma.My code is ---

Dim s1, strpid As String
Dim arr(), arr2()
Dim i As Integer
s1 = Request("PatientIDs")
arr = Split(s1, ":")
For i = 0 To UBound(arr)
arr2 = Split(arr(i), ">")
strpid = ("'" & arr2(0) & "'" & ",")
Response.Write(strpid)
Next

Plz reply.
i was reading your long conversation.....CyberSoft has correctly given you the solution........but if it sounds a bit confusing I am giving you a second method ...you may try it.......hope it will work

[size=2][/size]
Expand|Select|Wrap|Line Numbers
  1.  Dim str As String = "' B193 ',' H13 ',' H14 '," 
  2. str = str.TrimEnd(",")
  3. MsgBox(str)
  4.  
Jan 14 '08 #12
This seems you never got the concept.
Where you receiving the value “' B193 ',' H13 ',' H14 ',”?
Note: You have to try (Giving the solution to a homework will be a spam here) I pointed that is exactly correct but the thing is where you are applying!) try Survana you can do?... Come..on).
Thanks for ur reply.Finally I got it!
Jan 14 '08 #13
i was reading your long conversation.....CyberSoft has correctly given you the solution........but if it sounds a bit confusing I am giving you a second method ...you may try it.......hope it will work

[size=2][/size]
Expand|Select|Wrap|Line Numbers
  1.  Dim str As String = "' B193 ',' H13 ',' H14 '," 
  2. str = str.TrimEnd(",")
  3. MsgBox(str)
  4.  

Thaks for ur reply,I got it.
Jan 14 '08 #14

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

Similar topics

9
by: ted | last post by:
I'm having trouble using the re module to remove empty lines in a file. Here's what I thought would work, but it doesn't: import re f = open("old_site/index.html") for line in f: line =...
4
by: Stitch Jones | last post by:
I'm trying to get part of my perl script using a regex to get rid of an entire field between two ,'s I'm doing this to get a .csv formated alot nicer. here is an example of my issue user...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
3
by: blackdevil1979 | last post by:
Hi, I use a combobox to get a list of fruits (_SelectedIndexChanged)... I manage to get Apple, Orange, Grape, The question: How to get rid of the last comma (Grape , <--)
6
by: Rimuen | last post by:
Have a string contains numbers from database. But there is similar numbers want to remove Example: 1,3,6,6,6,12,13,14,15,15,15,15 Want to remove the similar numbers so it would be like:...
5
by: SuvarnaChaudhari | last post by:
Thanks lot!Its working,but I have again one doubt.I have created string but it looks like ('3435','4546','546',).So plz tell me how to remove that last one comma,so that I can pass it thru sql query...
2
by: Dennis | last post by:
Here is what I am trying to do... I have an XML doc that looks like: <root> <node>value1</node> <node>value2</node> <node>value3</node> <node>value4</node> </root>
3
by: maheswaran | last post by:
Hi I have this (for sampple) abc,cde,efg,ghc, How can i remove this last , I knew there is a option using reqular expreesion but could not find the answer....
4
anfetienne
by: anfetienne | last post by:
hi im back again.......i have a code to create strings and save it within a text file to pass variables to flash. im using the string format below. ...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.