Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through a string 1

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
Hello everyone. I was wondering if someone could show me the most efficient way to loop through a character string. I'm going to take the data from a notes field and put it in a variable. I then need to look for characters ascii(30) and ascii(31). When I find 31, I will need to tab. When I find 31, I will need a carriage return. Any help you can provide will be greatly appreciated.
 
<%
'ParseEntries(Actual String, Sepaarator)
call ParseEntries(&quot;100;200;300&quot; , &quot;;&quot;)
%>




<%
'Parsing based on Separator
Sub ParseEntries(sBuffer,sSeparator)

Response.Write &quot;Actual String for Parsing= &quot; & sBuffer & &quot;<br>&quot;
Response.Write &quot;Token Separator= &quot; & sSeparator & &quot;<br>&quot;
Response.Write &quot;Parsed Results <br><br>&quot;

dim sActualBuffer

sActualBuffer=sBuffer

if sBuffer=&quot;&quot; OR len(sBuffer)=0 then
Response.Write &quot;Error! No Entries Found&quot;
else
'Loop through each entry and Create Drop DOwn List . . .
nTotalEntries = 0
sEntries = &quot;&quot; 'Final Output
bMultipleFlag = True 'Assume Initially
intStart = 1 'Start from Initial String . . . .
Do While bMultipleFlag
sBuffer = Trim(Mid(sBuffer, intStart, Len(sBuffer)))
intStart = InStr(1, sBuffer, sSeparator, 1)

If intStart = 0 Then 'This is for Last and final Entry
If Len(sBuffer) > 0 Then
nTotalEntries = nTotalEntries +1
Response.Write sBuffer & &quot;<BR>&quot;
end if
bMultipleFlag = False
Exit Do
End If

If intStart > 0 Then intStart = intStart + 1
sEntry = Trim(Mid(sBuffer, 1, intStart - 2))

Response.Write sEntry & &quot;<BR>&quot; 'Show it on screen

nTotalEntries = nTotalEntries + 1
Loop
end if

end Sub
%>
 
replace( cMyString, chr(30), chr(9) ) ' tab

replace( cMyString, chr(31), chr(13) ) ' cr






hth,
Foxbox
ttmug.gif
 
<off topic>
foxbox, love the gif in the sig!
</topic>

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
[more off topic]
[thumbsup]

I need my daily shot of caffeine with my original Tek-Tips Mug!

[/more off topic]

hth,
Foxbox
ttmug.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top