Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 14th, 2006, 05:41 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
Split Function - Determine the point in which the string was split.

Hi Guys,

I’m trying to split a string using the split function. I can split it fine using the split function, but I want to know the exact point(s) that the string has been split. Anyone got a good way of doing this?

I really need to know the exact points of the split. I know that I could do this by making my own Split function that consists of a few Do Whiles - but that would be very CPU intensive, and I dont want to go there.

(p.s. The happy mothers’ day logo scared the sh*t out of me. I only just realized that the US mothers’ day is different to the UK mothers’ day!).
__________________
LozWare Website Directory

Whooo! Free submissions, no recip needed. I'm a nice guy

Reply With Quote
  #2  
Old May 14th, 2006, 05:46 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
Don't worry, I think that I have just figure out how to do it.

Reply With Quote
  #3  
Old May 15th, 2006, 05:59 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 36 m 35 sec
Reputation Power: 1243
One method of doing it

Hi,

I know you said you think you have the solution but I thought I would post this to demonstrate one method of doing it for anyone who is curious. The idea is that you could just split the string as normal using the Split function and use the Len function to get the length of each portion, adding one to this would give the position that the string was split at.

I.e. if the first portion of the string is 8 characters long then it would have been split at position 9, if the second portion of the string is 4 characters long then it would have been split at position 14. Len(first string) = 8 + 1 + Len(second string) = 4 + 1

The whole thing would look something like this:

Code:
Dim original_string As String 'The original string to be split
Dim splitarray() As String 'Array to hold the portions of the string
Dim posarray() As String 'Array to hold the split positions
Dim runningtotal As Integer 'Variable to keep a count of the positions
Dim a As Integer 'Counter for Loop
	
Private Sub Command1_Click()
	runningtotal = 0
	'String to split
	original_string = "this-is-a-string"
	'Split the string and store the portions in an array
	splitarray = Split(original_string, "-")
	ReDim posarray(1)
	For a = 0 To UBound(splitarray)
		If a > 1 Then ReDim Preserve posarray(UBound(posarray) + 1)
		'Add position of split to the running total
		'Position of split is equal to the length of the current 
		'array element plus 1
		runningtotal = runningtotal + Len(splitarray(a)) + 1
		posarray(a) = runningtotal
	Next
End Sub


The positions of the splits will now be stored in an array called posarray which should have the same subscript positions as the strings to which they refer. Note, the last position of the posarray will contain the position of the end of the string so can be disregarded. By swapping two lines
over so that you write the runningtotal to the posarray before you calculate the split position:

Code:
posarray(a) = runningtotal
runningtotal = runningtotal + Len(splitarray(a)) + 1


The first position of your posarray will now contain zero, the second element will contain the position of the first split etc. which may be better!!

This is probably the same logic that you used, if not then I would be interested to see how you accomplished it!!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Split Function - Determine the point in which the string was split.


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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT