after i have found whether or not the string has a "-" inside it i want to
run a split function on the string so another solution to the problem might
be along the lines of:
tempA = Split(FileArray(f), "-") 'split the current file name
'IF FileArray was split then...
With CurrentDocument
With ListBox1
.AddItem tempA(0) + " " + tempA(1)
End With
End With
so only insert the split file name into the list box if there was a split
array done.
Is there a way to check if the string was split?
> I would like to seach a string (an example of the string is
> "template1-letter_head_template.doc" ) to see if it contains a "-" symbol and
[quoted text clipped - 3 lines]
> search the string - there is a replace function so i guessed there must be
> one!
Jay Freedman - 12 Jun 2007 17:29 GMT
The variable tempA must be declared as a Variant datatype (although that's
the default datatype, so you can get away with not declaring it, but you
should declare it anyway to prevent bugs). A Variant can be considered to be
an array, and the UBound function will tell you the largest value of that
array's subscript. If there wasn't any "-", the entire string will be in one
element of tempA, so both the lower bound and the upper bound of tempA will
be 0. If there were one or more "-" characters, then the upper bound will be
bigger to hold all the pieces from the Split.
So this is your If statement:
If UBound(tempA) > 0 Then ' FileArray(f) was split

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> after i have found whether or not the string has a "-" inside it i
> want to run a split function on the string so another solution to the
[quoted text clipped - 21 lines]
>> function to search the string - there is a replace function so i
>> guessed there must be one!
>I would like to seach a string (an example of the string is
> "template1-letter_head_template.doc" ) to see if it contains a "-" symbol
[quoted text clipped - 4 lines]
> search the string - there is a replace function so i guessed there must be
> one!
If InStr(mystring, "-") > 0 Then
'mystring contains a hyphen
Else
'it doesn't
End If

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org