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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COUNT ITEMS SEPARATED BY SEMICOLON 2

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
0
0
CA
I have a form with a text field, when user enters info as follow
1;rty;POI,


I want to put another field on the form where it displays the total. I have done any programming for a while and I was wondering if anyone can point on the right direction or the beggining of what the function should be.

thank you

 
What exactly do you wish to total, a item extracted from the text field?
 
Hi,

The following code should do what you are looking for.

Dim position As Integer
Dim count As Integer

count = 0
position = 1

While position <> 0
position = InStr(position + 1, stringname, &quot;;&quot;)
If position <> 0 Then
count = count + 1
End If
Wend

count = count + 1

This code counts the number of items in the string that are delimited by a semicolon. Just replace stringname with the name of your field.

Best,
dz
dzaccess@yahoo.com
 
You're right, yotwiggy...I had the same question, and may have misinterpreted villica's question. dz
dzaccess@yahoo.com
 
MyVar = Split(the string, &quot;;&quot;)
NumItems = UBound(MyVar) + 1

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I apologize everyone. I guess I was not very clear.

This is what I would like to accomplish
r2;yu1;po
count = 3


Foxprogramer and MichaelRed, thank you for the code. I will give these a try. I appreciate your time.


 
I apologize everyone. I guess I was not very clear.

This is what I would like to accomplish
r2;yu1;po
count = 3


Foxprogramer and MichaelRed, thank you for the code. I will give these a try. I appreciate your time.


 
Hi Michael,

I have used the Split function before, and initially thought that it could be used to solve villica's issue. However, I didn't know about the Ubound function and couldn't think of a way to return the size of the array. I also found Lbound when I looked in the Help. If you don't know what you are looking for in the Help, it's hard to find! Thanks a lot for the tip. The Ubound and Lbound functions will come in handy in the future.

Best wishes, dz
dzaccess@yahoo.com
 
Thank you forproprogrammer.It works. MichaelRed I was not able to use the split function. It must be access 2000 and I am using 97.
thank you both of you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top