Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2007, 12:43 PM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Textbox value array

Hi,

I'm looking to call upon the communities expertise, I have a bit of trouble with the following.

In a userform I have 6 textbox's on which contain workbook filepath references that the user has entered. I wish to take those file references and return them in msgbox's (later use them to open workbooks). Does anybody have any idesor sample code, I tried using the for statement but can't get it right.

Thanks for your help in advance.

Stuart McKay

 
Old March 16th, 2007, 02:54 PM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi guys,
it appear i've answered my own question:-

Dim IntNo As Integer
Dim StrUname As String


For IntNo = 2 To 7 Step 1
StrUname = "Textbox" + CStr(IntNo)
If Controls(StrUname).Value <> "" Then
MsgBox Controls(StrUname).Value
Else
MsgBox ("Blank")
End If
Next


End Sub

 
Old March 16th, 2007, 03:16 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I'd concatenate instead of using + CStr and use it with the if then to minimize the code, myself.

------------------------------------------------------------------------------------
Dim IntNo As Integer, sMsg As String
For IntNo = 2 To 7 Step 1 'Step 1 is actually optional, incrementing by 1 is default
  sMsg = Controls("TextBox" & IntNo).Value
  If sMsg = "" then sMsg = "Blank"
  MsgBox sMsg
Next
------------------------------------------------------------------------------------

Just trying to be helpful.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
control array of textbox greatmanu Excel VBA 1 October 24th, 2003 09:36 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.