Count Command?

rjusa

New member
Local time
Today, 09:16
Joined
Feb 27, 2003
Messages
7
Thanks to Pat, I've come up with the following code:

Sub Macro69()
Dim Mystring As String, MyArray, Msg
DoCmd.OpenForm "String"
Mystring = Forms!String!Address
MyArray = Split(Mystring, "*", -1, 1)
Msg = MyArray(0)
MsgBox Msg
Msg = MyArray(1)
MsgBox Msg
End Sub

Returned excatly what I needed. Thank you Pat! Next, my question is:

I knew apriori how to set the MyArray parameters (i.e., 0, 1)...since I don't have this luxury in the real world, how can I incorporate code to count the number of times the "*" character occurs (n) and then alter the existing code to tell MyArray to loop(?) 1 to n times?
 
Try this:

Code:
Sub Macro69() 
Dim Mystring As String, MyArray, Msg 
Dim iLP as Integer
  DoCmd.OpenForm "String" 
  Mystring = Forms!String!Address 
  MyArray = Split(Mystring, "*", -1, 1) 
  For iLP=lbound(MyString) to ubound(MyString)
    Msg = MyArray(iLP) 
    MsgBox Msg 
  Next iLP
End Sub

lbound is the Lower limit of an Array (Never assume 0, you don't know who was coding)

ubound is the Upper limit of an Array.
 

Users who are viewing this thread

Back
Top Bottom