Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Algorithm Problem

Hi

I have a string which I would like to pass into my code

The string -

SBR_1_Ammonia,01246,0.15,,SBR_2_Ammonia,01246,0.94 ,,SBR_3_Ammonia,01246,0.11,,SBR_4_Ammonia,01246,0. 01,,,


Broken down this means Name ,WeekDay ,Previous Value

There are 4 records in the string each is separated by double commas, the
end of the string is found by three commas each piece of the record is
separated with a single comma

looking at the first record it is -

SBR_1_Ammonia - Name
01246 - Monday, Tuesday, Wednesday, Friday, Sunday - Weekdays to be
included.
0.15 - Previous Value

Lets say it is monday.

The 0 indicates monday so I would like to check through the records
collecting the values which have a flag for this day.

All the records have a 0 so the string outut would look like -

SBR_1_Ammonia,01246,0.15,,SBR_2_Ammonia,01246,0.94 ,,SBR_3_Ammonia,01246,0.11,,SBR_4_Ammonia,01246,0. 01,,,


but suppose only the first and last records contained the 0 it would only
show

SBR_1_Ammonia,01246,0.15,,SBR_4_Ammonia,01246,0.01 ,,,


Thanks for your assistance with this. I want to do some other things to it
aswell but one step at a time.

Rob



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 733
Default Algorithm Problem

Rob Hargreaves wrote...
I have a string which I would like to pass into my code

The string -

SBR_1_Ammonia,01246,0.15,,SBR_2_Ammonia,01246,0.9 4,,
SBR_3_Ammonia,01246,0.11,,SBR_4_Ammonia,01246,0.0 1,,,

Broken down this means Name ,WeekDay ,Previous Value

There are 4 records in the string each is separated by double commas, the
end of the string is found by three commas each piece of the record is
separated with a single comma

looking at the first record it is -

SBR_1_Ammonia - Name
01246 - Monday, Tuesday, Wednesday, Friday, Sunday - Weekdays to be
included.
0.15 - Previous Value

....
but suppose only the first and last records contained the 0 it would only
show

SBR_1_Ammonia,01246,0.15,,SBR_4_Ammonia,01246,0.0 1,,,

....

Just a parsing problem. Pass such strings through the
following function.


Function parser(s As String) As String
Dim t As String, n As Long
Dim a As Variant, b As Variant

t = Replace(s, ",,,", "")
t = Replace(t, ",,", Chr(28))
a = Split(t, Chr(28))

t = ""
For n = LBound(a) To UBound(a)
b = Split(a(n), ",")
If b(1) Like "*0*" Then t = t & ",," & a(n)
Erase b
Next n

Erase a

parser = Mid(t, 3) & ",,,"
End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Algorithm Problem

Thanks Harlan,

Thats great. I dont understand how you did it though.

I can handle more basic code but how do you find good information on how to
write that sort of stuff?

Rob



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 733
Default Algorithm Problem

Rob Hargreaves wrote...
....
I can handle more basic code but how do you find good information on how to
write that sort of stuff?

....

Reading general programming books and just writing code are the best
ways to learn how to write code. Books focussed on VBA are unlikely to
be much use except as references. If you're looking for book
recommendations, my favorites are a bit old (but still excellent
texts): Jon Bentley's two Programming Pearls books and Kernighan and
Plaugher's The Elements of Programming Style.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Algorithm Challenge Lowkey Excel Programming 5 July 19th 05 04:34 PM
algorithm creation Gixxer_J_97[_2_] Excel Programming 11 February 11th 05 04:24 PM
can't find problem with permutation algorithm margie[_9_] Excel Programming 2 March 2nd 04 01:01 AM
help with algorithm dreamer[_3_] Excel Programming 6 January 9th 04 02:14 PM
Need help with algorithm RADO[_3_] Excel Programming 1 November 4th 03 12:37 PM


All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"