variable nam in VB

  • Thread starter Thread starter Brettjg
  • Start date Start date
B

Brettjg

I've specified
Dim mem1, mem2, mem3
counter = 1

and I want to run through a loop such as
Do while counter <= 3
Msgbox "Name = " & mem & counter
counter = counter + 1
Loop

to show 3 Msgboxes, but VB doesn't like "mem & counter".

How do I express "mem & counter please?
Also, what do you actually call things like mem1, mem2? Are they simply
called dimensions or..........
Regards, Bret
 
not sure what you're trying to do, but maybe this will help

Sub test()
Dim mem(3) As String
Dim counter As Long

Do While counter <= 2
MsgBox "Name = " & mem(counter) & counter
counter = counter + 1
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top