RE: referring to increasing VBA variable name in loop



Hi,
Try using an array of strings:
'''--------------------------------
Dim i as long
Dim Phrase() as string

Redim Phrase(1 to 30)
Phrase(1)="Hello"
Phrase(2)= ...
...
Phrase(30) = "End"

''' speak
For i =1 to 30
XL.Speech.Speak Phrase(i)
Next
''' ----------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com>


"ucdcrush@xxxxxxxxx" wrote:

I am using VBA to put together some phrases to be spoken with the text
to speech feature in excel.

What I've got is a list of string variables,

Phrase1
Phrase2
Phrase3
....
Phrase30

which are set equal to different words or phrases such as
Phrase1 = "Hello"

I can hard-code a variable name into the speech code such as:

XL.Speech.Speak Phrase1

this will successfully speak the string assigned to Phrase1.

What Im having trouble with is referring to the Phrase1-30 variables
in a for loop, something like

for i = 1 to 30
xl.speech.speak phrase & i
next

This code doesn't produce any speech, I'm assuming because the
variable name isn't being passed as intended. How can I refer to
variables within a loop, when the loop # (i) is part of the variable
name?

Thanks.

.



Relevant Pages

  • Re: Tiempo de Zamba
    ... all the way up to bar with the 1st finger on the last chords of m.s 8 ... third string, 2 on second on same fret). ... sort of growth wrapping up each phrase, ... After the overt character of this opening, the phrase of m. s 9-12 ...
    (rec.music.classical.guitar)
  • Re: Tiempo de Zamba
    ... all the way up to bar with the 1st finger on the last chords of m.s 8 ... third string, 2 on second on same fret). ... sort of growth wrapping up each phrase, ... After the overt character of this opening, the phrase of m. s 9-12 ...
    (rec.music.classical.guitar)
  • Re: Tiempo de Zamba
    ... prosaic and obvious fingerings. ... third string, 2 on second on same fret). ... sort of growth wrapping up each phrase, ... consider that it is a dance piece. ...
    (rec.music.classical.guitar)
  • Re: getting the thing to be LL(1)
    ... WORD) or PHRASE expressions, and any field specifications must be the same. ... public QueryParser(java.io.Reader stream, int nearNumDefault) ... String[] fpA; ... String nearOp(): ...
    (comp.compilers.tools.javacc)
  • Re: Create Acronym (Extract first letter of each word)
    ... Function Acronym(phrase As String) As String ... Dim ch As String, words As String ... Put your phrase in A1, ... Dim I As Integer, myWord As String ...
    (microsoft.public.excel.worksheet.functions)