troubleshooting Question

Modify variables in VBA

Avatar of DrTribos
DrTribosFlag for Australia asked on
Visual Basic ClassicProgrammingVB Script
21 Comments2 Solutions532 ViewsLast Modified:
Hi All

I have a bunch of variables in my code with the same name except for the last character.

Rather than have a select case statement I'd like to combine 2 variables...

e.g. I might have the following variables...

Dim PicJPG as string
Dim PicPNG as string
Dim PicBMP as string
Dim PicGIF as string

I want to assign a value to the variable like this

Pic & right(filename, 3) = thisdocument.path & filename

instead of

Select Case right(filename, 3)
Case JPG
   PicJPG = ....

and so on... I have a lot of cases!

This is specifically for VBA

Join our community to see this answer!
Unlock 2 Answers and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros