Is it possible to loop through text?

  • Thread starter Thread starter Sam Kuo
  • Start date Start date
S

Sam Kuo

Is it possible to loop through text, as it would for number? For example:

Dim Text As Integer ' where Text = "Before", "Now", or "After"
For Text
' code goes here
' i.e. Me.Controls("txt" & Text).Visible = True
Next Text
 
Dim sText As String
Dim ary As Variant
Dim i As Long

sText = "Before,Now,After"
ary = Split(sText, ",")
For i = LBound(ary) To UBound(ary)

'Me.Controls("txt" & ary(i)).Visible = True


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
It can be done this way also...

Dim V As Variant
For Each V In Split("Before,Now,After", ",")
Me.Controls("txt" & V).Visible = True
Next

Rick
 
Hi Bob and Rick
Thanks alot!

Rick Rothstein (MVP - VB) said:
It can be done this way also...

Dim V As Variant
For Each V In Split("Before,Now,After", ",")
Me.Controls("txt" & V).Visible = True
Next

Rick
 

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