ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 5th, 2006, 11:30 AM
gandhiaryah gandhiaryah is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 2 gandhiaryah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Vb6 code for convert number sequence to range

Hello All,

I want the code in vb6 to convert the following number sequence in the input string
input="1,3,4,5,7,8,9,13,17,18,19" to the following output string
out="1,3-5,7-9,13,17-19"

Anyone can help me.

Thanks in Advance.

Regards
Gandhimathi

Reply With Quote
  #2  
Old December 6th, 2006, 03:59 AM
tiewen tiewen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Location: shanghai,china
Posts: 10 tiewen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 28 m 6 sec
Reputation Power: 0
Send a message via MSN to tiewen
i dont know vb well,but in JScript,it's easy:
<% @Language = "JScript" %>
<% Response.buffer = true %>

<%
var input="1,3,4,5,7,8,9,13,17,18,19,21,22,24,26,27";
var s=input.split(',');
for(var i=0;i<s.length;i++)
{
if(parseInt(s[i])%2==0) s[i]="-";
}
var output=s.join(',');
while(output.indexOf('-,-,')>-1)
{
output=output.replace(/-,-,/ig,'-,');
}
output=output.replace(/,-,/ig,'-');
Response.Write(output);

%>

Reply With Quote
  #3  
Old December 6th, 2006, 12:56 PM
gandhiaryah gandhiaryah is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 2 gandhiaryah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Need help in string handling

Hello,
I want to extract the continuous number sequence in the string. The following code works fine. But I want the code in simple way.


Code:
Sub sequence()
a = "3,4,7,8,9,12,14,15,16,19"
arr = Split(a, ",")
Do While i <= UBound(arr)
If Val(arr(i) + 1) = Val(arr(i + 1)) Then
j = 0
Do While Val(arr(i) + j) = Val(arr(i + j))
If InStr(st, Val(arr(i + j))) = 0 Then
st = st & "-" & arr(i + j)
nst = nst & arr(i + j) & ","
End If
j = j + 1
If i + j > UBound(arr) Then
Exit Do
End If
Loop
If nst <> Empty Then
MsgBox Left(nst, Len(nst) - 1)
End If
nst = Empty
End If
If i = UBound(arr) - 1 Then
Exit Do
End If
i = i + 1
Loop
End Sub


Thank you,
Regards
Gandhimathi

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Vb6 code for convert number sequence to range


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap