array to pull string positions
say i've got a field in my database that contains a string of 13 "1's" and "0's" ..
like so:
0110001011001
each one represents a yes or a no in a questionaire taken from an application on one of our other sites.. this information needs to be taken into another asp page that will parse the 10101 string and tell it to check the corresponding box with a yes or no checkmark..
(
Dim strboxchecked, strbox
strboxchecked=""
strbox=""
)
The page that I'm filling is an html built mortgage application and HAS to appear the same as it does on paper.
Can I write an array to count each position in the string, return it into a variable, and subsequently check the correct box on the page.
I know I can I just can't seem to get anything working.. any ideas?
Thanks
Aaron Elliott
forwardtrends.com
Mark Hensler posted this at 18:03 — 27th February 2003.
He has: 4,048 posts
Joined: Aug 2000
I'm guessing you want ASP code, because you had a Dim statement.
This isn't tested, but should give you an idea...
<%
Option Explicit
Function CheckValue(strDigits, intPosition)
' INPUTS:
' strDigits - string containing 1's and 0's
' intPosition - zero based index
'
' RETURN:
' If the digit at the intPosition offset is a 1, function will return TRUE.
' If the digit at the intPosition offset is a 0, function will return FALSE.
'
If Len(strDigits) <= intPosition OR intPosition < 0 Then
CheckValue = TRUE
Exit Function
End If
If Mid(strDigits, intPosition, 1) = "1" Then
CheckValue = TRUE
Else
CheckValue = FALSE
End If
End Function
Dim strDigits as String
Dim i as Integer
Response.Write "<html><body><pre>"
strDigits = "0110001011001"
For i=0 to 12
arrDigits(i) = CheckValue(strDigits, i)
Next
Response.Write "</pre></body></html>"
%>
Mark Hensler
If there is no answer on Google, then there is no question.
forwardtrends posted this at 18:18 — 27th February 2003.
He has: 52 posts
Joined: Feb 2003
thats exactly what I was looking for - thanks!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.