By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Counting characters and splitting string

P: n/a
1. Is there an easy function in VB to count for instance the number of A's
in a string?
2. Is there an easy funtion in VB to pull all characters out of a string
into an array? (I tried the split function but that needs a separator.)
Thanks,
john
Jul 20 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
1. Look at the Instr function in the Help file.
2. Dim i As Integer
Dim MyArray As Variant
For i = 1 to Len(MyString)
MyArray(i) = Mid(i,1)
Next i

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com

"John" <xx*@yyy.comwrote in message
news:f7**********@textnews.wanadoo.nl...
1. Is there an easy function in VB to count for instance the number of A's
in a string?
2. Is there an easy funtion in VB to pull all characters out of a string
into an array? (I tried the split function but that needs a separator.)
Thanks,
john

Jul 20 '07 #2

P: n/a
On Fri, 20 Jul 2007 23:08:32 +0200, John wrote:
1. Is there an easy function in VB to count for instance the number of A's
in a string?
In a Query?
CountInString: (Len([FieldName])-Len(Replace([FieldName],"A","")))/1
2. Is there an easy funtion in VB to pull all characters out of a string
into an array? (I tried the split function but that needs a separator.)
Thanks,
john

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jul 20 '07 #3

P: n/a
Could you clarify, Steve? Your first suggestion appears incomplete and the
second does not seem to work, even if MyString is dimensioned/provided.

"Steve" <So***@private.emailaddresswrote in message
news:AV****************@newsread2.news.pas.earthli nk.net...
1. Look at the Instr function in the Help file.
2. Dim i As Integer
Dim MyArray As Variant
For i = 1 to Len(MyString)
MyArray(i) = Mid(i,1)
Next i

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com

"John" <xx*@yyy.comwrote in message
news:f7**********@textnews.wanadoo.nl...
>1. Is there an easy function in VB to count for instance the number of
A's in a string?
2. Is there an easy funtion in VB to pull all characters out of a string
into an array? (I tried the split function but that needs a separator.)
Thanks,
john


Jul 21 '07 #4

P: n/a
1. The Instr function finds the occurrence of one string within another.
The OP needs to build a routine around the InStr function.
2. Brain was working faster than fingers! MyArray(i) = Mid(i,1) should be:
MyArray(i) = Mid([MyString],i,1)

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com


"Larry Linson" <bo*****@localhost.notwrote in message
news:mhfoi.516$7w.381@trnddc05...
Could you clarify, Steve? Your first suggestion appears incomplete and
the second does not seem to work, even if MyString is
dimensioned/provided.

"Steve" <So***@private.emailaddresswrote in message
news:AV****************@newsread2.news.pas.earthli nk.net...
>1. Look at the Instr function in the Help file.
2. Dim i As Integer
Dim MyArray As Variant
For i = 1 to Len(MyString)
MyArray(i) = Mid(i,1)
Next i

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com

"John" <xx*@yyy.comwrote in message
news:f7**********@textnews.wanadoo.nl...
>>1. Is there an easy function in VB to count for instance the number of
A's in a string?
2. Is there an easy funtion in VB to pull all characters out of a string
into an array? (I tried the split function but that needs a separator.)
Thanks,
john



Jul 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.