Tom
Mon Jul 10 22:45:05 CDT 2006
Like I said - I must have been missing something. I scanned earlier
responses, but missed the reference to Instr().
Tom Lavedas
Bob Barrows [MVP] wrote:
> I was just answering the question, which was how to turn that string into an
> array. I'm still not clear about why he wants to do it.
>
> Earlier responses had mentioned using InStr(), and since abcd kept asking, I
> assumed InStr() was not the answer he was looking for.
>
> Tom Lavedas wrote:
> > Wait. What am I missing. If the OP wants to find if a character
> > resides in a string, why not use the InStr() method? This approach
> > also provides the position of that character in the string. If
> > multiple occurrences are expected and their positions desired, a
> > search could be done something like this ...
> >
> > s="abcdefgabcdefg"
> > cSearch = "d"
> >
> > nPosition = InStr(s, cSearch)
> > if nPosition = 0 then
> > sOutput = "The character was not found in the string."
> > else
> > sOutput = "The character was found." _
> > & vbNewline & "The occurrence(s) is(are) at: "
> > Do
> > sOutput = sOutput & " " & nPosition
> > nPosition = InStr(nPosition + 1, s, cSearch)
> > Loop until nPosition = 0
> > end if
> > msgbox sOutput
> >
> > Tom Lavedas
> > =============
> >
http://members.cox.net/tglbatch/wsh
> >
> > Bob Barrows [MVP] wrote:
> >> Since there are no delimiters, you are forced to loop through the
> >> string:
> >> dim s, a(), x, i
> >> s="abcdefg"
> >> x=len(s) - 1
> >> redim a(x)
> >> for i = 0 to x
> >> a(i) = mid(s,i,1)
> >> next
> >>
> >>
> >> abcd wrote:
> >>> input string "abcdefg"
> >>>
> >>> how can I convert this string into array so that I get the values
> >>>
> >>> dim a
> >>>
> >>> a(0) ="a"
> >>> a(1) ="b"
> >>> a(2) ="c"
> >>> a(3) ="d"
> >>> a(4) ="e"
> >>> a(5) ="f"
> >>> a(6) ="g"
> >>>
> >>>
> >>>
> >>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> >>> news:%23njcCLFpGHA.756@TK2MSFTNGP05.phx.gbl...
> >>>> Provide an example of the string you want to split into an array, a
> >>>> description of how the string is delimited, and an illustration of
> >>>> the array you wish to generate.
> >>>>
> >>>> abcd wrote:
> >>>>> a = Split(s,",")
> >>>>>
> >>>>> this statement didnt convert the string to an array of chars....
> >>>>>
> >>>>> I get a(0) as the whole string value
> >>>>> there is no a(1).....a(n) values
> >>>>>
> >>>>> "McKirahan" <News@McKirahan.com> wrote in message
> >>>>> news:ltadnRAX6_B9BC_ZnZ2dnUVZ_qqdnZ2d@comcast.com...
> >>>>>> "abcd" <abcd@abcd.com> wrote in message
> >>>>>> news:uLaVerEpGHA.3936@TK2MSFTNGP04.phx.gbl...
> >>>>>>> How to convert string to Array in VB/VBScript
> >>>>>>>
> >>>>>>> I have a string and I need to parse each chars to check if that
> >>>>>>> chars is the one I am looking for...looks simple ut not striking
> >>>>>>> me at this moment....
> >>>>>>>
> >>>>>>> I was planning to iterating the array to its length and find out
> >>>>>>> the chars
> >>>>>>> by ASC function....
> >>>>>>
> >>>>>> Are you looking for one of these?
> >>>>>>
> >>>>>> Dim a
> >>>>>> a = Split(s,",")
> >>>>>> Dim i
> >>>>>> For i = 0 To UBound(a)
> >>>>>> If a(i) = "your character test" Then ...
> >>>>>> Next
> >>>>>>
> >>>>>>
> >>>>>> If InStr(s,"your character test") > 0 Then ...
> >>>>>>
> >>>>>>
> >>>>>> If not then provide more information.
> >>>>
> >>>> --
> >>>> Microsoft MVP -- ASP/ASP.NET
> >>>> Please reply to the newsgroup. The email account listed in my From
> >>>> header is my spam trap, so I don't check it very often. You will
> >>>> get a quicker response by posting to the newsgroup.
> >>
> >> --
> >> Microsoft MVP -- ASP/ASP.NET
> >> Please reply to the newsgroup. The email account listed in my From
> >> header is my spam trap, so I don't check it very often. You will get
> >> a quicker response by posting to the newsgroup.
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"