Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

vba newbie question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vbaNOOB - 07 Mar 2007 15:19 GMT
Hi all,

I want to create a vba program that allow user to input a num(eg 3)
Then the program will add 3 textbox in the form

The problem is how I can get the value of these textbox?
The easiest way to do that is I create couple of textbox in the form, and
hide them
When the user enter 3, I just show the first 3 textbox. Also, I can get the
text from the textbox, becoz the textbox exist.

Is there a better way to do it??
For other language, I can run a string as a line of code. As I know, vba
can't....

Dim i as integer
for i = 1 to num ( from user)
   textbox & "i".text = "hihi"  <---- I know I cant do it @@
next

Sorry for my bad English. I hope u guys understand what I'm saying
Thanks
Helmut Weber - 07 Mar 2007 15:41 GMT
Hi,

one way:

Private Sub CommandButton1_Click()
Dim l As Long
For l = 1 To 3
  Me.Controls("textbox" & CStr(i)).Text = CStr(i)
Next
End Sub

Another way is to google in the groups for

array controls

and my decent name,

on how to create an array of controls at runtime.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.