Re: referring to increasing VBA variable name in loop
I think you should be using an array for this...
Dim Phrase(1 To 30) As String
Phrase(1) = "Hello"
Phrase(2) = "Good-bye"
etc....
.......
For i = 1 To 30
xl.Speech.Speak Phrase(i)
Next
Rick
<ucdcrush@xxxxxxxxx> wrote in message
news:780e298b-60ad-4ce0-b575-6d66dfd04efc@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
- referring to increasing VBA variable name in loop
... I am using VBA to put together some phrases to be spoken with the text ... I can hard-code a variable name into the speech code such as: ... in a for loop, something like ... (microsoft.public.excel.programming) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) |
|