ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   throw string (https://www.excelbanter.com/excel-programming/376072-throw-string.html)

x taol

throw string
 


sub sbTst()
msgbox 1
end sub

sub sbTst2()
msgbox 12
end sub

sub sbTst3()
msgbox 13
end sub

sub sProblem()
for i =1 to 3
call "sbTst" & i
next
end sub

This code not work.
How can I using Loop.?

*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips

throw string
 
sub sProblem()
for i =1 to 3
Application.run "sbTst" & i
next
end sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"x taol" wrote in message
...


sub sbTst()
msgbox 1
end sub

sub sbTst2()
msgbox 12
end sub

sub sbTst3()
msgbox 13
end sub

sub sProblem()
for i =1 to 3
call "sbTst" & i
next
end sub

This code not work.
How can I using Loop.?

*** Sent via Developersdex http://www.developersdex.com ***




Jim Thomlinson

throw string
 
You can't... procedure names can not be created from variables... What you
could do would be to pass an argument to the procedure to make it work.
Something like this.

Sub sbTst (byval lngMessage as long)
select case lngMessage
case 1
msgbox 1
case 2
msgbox 12
case 3
msgbox 13
case else
msgbox "Error"
end select
end sub

sub sProblem()
dim i as long
for i =1 to 3
call sbTst(i)
next
end sub
--
HTH...

Jim Thomlinson


"x taol" wrote:



sub sbTst()
msgbox 1
end sub

sub sbTst2()
msgbox 12
end sub

sub sbTst3()
msgbox 13
end sub

sub sProblem()
for i =1 to 3
call "sbTst" & i
next
end sub

This code not work.
How can I using Loop.?

*** Sent via Developersdex http://www.developersdex.com ***


Jim Thomlinson

throw string
 
Nice touch Bob. I never even though of using Application.Run. Note to the OP
however is that Application.Run has a bit of overhead associated with its
use. In this case it is probably not a big deal but just be aware that there
is a performace hit for using it. If the loop was a few thousand instead of
just a few it could become noticable...
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

sub sProblem()
for i =1 to 3
Application.run "sbTst" & i
next
end sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"x taol" wrote in message
...


sub sbTst()
msgbox 1
end sub

sub sbTst2()
msgbox 12
end sub

sub sbTst3()
msgbox 13
end sub

sub sProblem()
for i =1 to 3
call "sbTst" & i
next
end sub

This code not work.
How can I using Loop.?

*** Sent via Developersdex http://www.developersdex.com ***






All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com