Variable Control Names

Within a user form I am trying to reduce the amount of code needed to
enter text into text box

I have two text boxes. TextBox1 and TextBox2

When Command Button 1 is clicked I want the result
TextBox1.Text = "This is my test text"

When Command Button 2 is clicked I want the result
TextBox2.Text = "This is my test text"

But I wish to use the same piece of code for both examples.

I am missing something here. This is my test example.

_____________________________________________________________

Private Sub CommandButton1_Click()
setar (1)
'when Command Button 1 is clicked it sends the number 1 as a variable to
the code
End Sub
_____________________________________________________________

Private Sub CommandButton2_Click()
setar (2)
'when Command Button 2 is clicked it sends the number 2 as a variable to
the code
End Sub
_____________________________________________________________

Private Sub setar(ArgValue As Integer)
TextBoxArgValue.Text = "This is my test text"
'Missing something here
End Sub

Bottom Line
-----------

How do I get Argvalue to place itself between the x of TextBoxand the .

?

On a similar note, how do I add this number mid text?

When Command Button 1 is clicked I want the result
TextBox1.Text = "This is my test 1 text"

When Command Button 2 is clicked I want the result
TextBox2.Text = "This is my test 2 text"



Garry Jones
Sweden

PS, Yes I know I can get the same effect by using unique code in each
command button control. But I have 198 command buttons so I want to use
the same code 198 times.
0
morack (4)
10/1/2003 9:28:17 PM
excel 39879 articles. 2 followers. Follow

1 Replies
582 Views

Similar Articles

[PageSpeed] 38

Garry,

Try this for a start:

'--------
Private Sub setar(ArgValue As Integer)
    Dim boxName As String
    boxName = "Textbox" & ArgValue
    Me.Controls(boxName).Value = boxName
End Sub
'--------

HTH
Anders Silv�n

"Garry Jones" <morack@algonet.se> skrev i meddelandet
news:3F7B46F1.E0E92730@algonet.se...
> Within a user form I am trying to reduce the amount of code needed to
> enter text into text box
>
> I have two text boxes. TextBox1 and TextBox2
>
> When Command Button 1 is clicked I want the result
> TextBox1.Text = "This is my test text"
>
> When Command Button 2 is clicked I want the result
> TextBox2.Text = "This is my test text"
>
> But I wish to use the same piece of code for both examples.
>
> I am missing something here. This is my test example.
>
> _____________________________________________________________
>
> Private Sub CommandButton1_Click()
> setar (1)
> 'when Command Button 1 is clicked it sends the number 1 as a variable to
> the code
> End Sub
> _____________________________________________________________
>
> Private Sub CommandButton2_Click()
> setar (2)
> 'when Command Button 2 is clicked it sends the number 2 as a variable to
> the code
> End Sub
> _____________________________________________________________
>
> Private Sub setar(ArgValue As Integer)
> TextBoxArgValue.Text = "This is my test text"
> 'Missing something here
> End Sub
>
> Bottom Line
> -----------
>
> How do I get Argvalue to place itself between the x of TextBoxand the .
>
> ?
>
> On a similar note, how do I add this number mid text?
>
> When Command Button 1 is clicked I want the result
> TextBox1.Text = "This is my test 1 text"
>
> When Command Button 2 is clicked I want the result
> TextBox2.Text = "This is my test 2 text"
>
>
>
> Garry Jones
> Sweden
>
> PS, Yes I know I can get the same effect by using unique code in each
> command button control. But I have 198 command buttons so I want to use
> the same code 198 times.


0
10/1/2003 10:57:27 PM
Reply:

Similar Artilces:

Global variables - again
Hi, When I load my first form in the system, it reads in the following parameters from my INI file. User Name the DOS Path to the Data I store these two value in a global variable and only reference them from that point on. I use the user name to read in a row from the tblUserParm table that has all of the settings for that user. I use the DOS data path to get to different sub-directories under my Access db directory. I will also use it to make automatically re-do my links, but I am not at that point yet. Is this an appropriate use of global variables? Is there...

Truncate Table Table variable
Hi, Sql Server 2005 I am using table variable with in a stored procedure and within a table variable i am using identity field. Sometimes I required to truncate the table variable to rseed the identity, but truncate table variable, dbcc checkident are not working. Any idea... Declare @Columns Table(id Int Identity(1,1), [Name] VarChar(155)); Insert Into @Columns([Name]) Select 'A' Union All Select 'B' Select * From @Columns Truncate Table @Columns Insert Into @Columns([Name]) Select 'X' Union All Select 'Y' Select * From @Columns Ra...

Title Bar Control
I would like to put a custom control on the title bar of the main frame window. I know how to access the title bar area to change the title, but I'm not sure how to locate a control there. Any help to point me in the right direction would be appreciated. Thanks! Rick In the OnCreate method of your CMainFrame class, m_wndTitleBar.Create(this, IDD_TITLEBAR, CBRS_TOP, IDD_TITLEBAR); in the CMainFrame .h file CDialogBar m_wndTitleBar; "Rick" <anonymous@discussions.microsoft.com> wrote in message news:08e901c3a267$9d68fb20$a301280a@phx.gbl... > I would like to...

Environment variables
Are Windows XP x64 %environment variables% available to Excel and VB equations? The general answer is yes, but you need to understand that there are different views of the filesystem and registry for 32-bit programs as compared to 64-bit programs and the OS. This also affects things like ODBC sources as well. -- Charlie. http://msmvps.com/blogs/russel <johnsuth@nospam.com.au> wrote in message news:c1.2c.3KklPW$0TR@PC1.BIGPOND.COM... > > Are Windows XP x64 %environment variables% available to Excel and VB > equations? > > ...

Server config giving out Internal name
I received the following email after I tried sending an email. The fact that it was sent back is not the issue. What is the issue is that it showed my internal server name. Here is a snippit: >Received: from unknown (HELO XXX.internalname.local) (XXX.XX.XX.XX) > by name.name.net with SMTP; 10 Oct 2005 17:21:28 -0000 I changed some informtion. As you can see, the HELO statement contains my internal name. As I understand it, it should not be passed. How do I change this? I also believe that this my be the root of another problem. Thanks! Eric Change fqdn in SMTP Virtual Se...

How to stop highlighting items in Cedit control
I am using a Cedit control within a propertypage to display a list of status messages as the program executes a series of actions. Everything works OK, except that all of the text in the Cedit control is highlighted (selected?). Is there a way to insert data into the Cedit control without having the text highlighted? Call SetSel(-1,0) for the edit control to deselect the text. You can do this in an update routine. Tom "Brian Westcott" <bwestcott@shaw.ca> wrote in message news:%237U9muIlGHA.1320@TK2MSFTNGP04.phx.gbl... >I am using a Cedit control within a propert...

Wordwrap Edit Control
My app allows the user to check a short txt or log file. The text file size is less than 100 characters, maybe less than 50. It reads the file to a character array and I use SetDlgItemText to put in into the Edit control. Is there a way to using the Edit control settings to wordwrap text? I know I can work around it by breaking up the character array (or CString) writing lines that will fit. Or I can use a messagbox which will wrap. Thanks in advance for any ideas. folderann schrieb: > Is there a way to using the Edit control settings to wordwrap text? Use ES_MULTILINE without ...

TEMP environment variable
Hi, Does somebody know what happens when I write in the 'TEMP' environment variable more than one directory, seperated by a ';' (For example 'C:\windows\temp ; d:\temp')? Does the OSs (98, 2000, XP) know to use BOTH directories as a temporary directories? Regards, Ram ...

Selecting & copying a named range through a listbox
When i click on a button i want a listbox to pop up. In this listbox there has to appear a list with named ranges. The named range which is selected in this listbox has to be copied Can somenone give me some code for this. That's it ! Thanxxx, Luc Since your post is kinda vague I will have to ask some questions and makes some assumptions. 1.) Are you wanting to select multiple ranges to be copied from a listbox or select a single range to be copied from a combobox? 2.) Where do you want the range copied to? Another worksheet, workbook, somewhere else withi...

List Control Images
I have looked all around, and still can't see why this doesn't work. I want to simply insert an image in a column of my list control. I can't seem to get my image past the first subitem, even if I use the LVITEM structure. It will display the images denoted fromthe image list, bu only in the first column. Also when I use SetImageList for my control, The first image ion the list always appears before any text I insert in the first column. If I comment out the SetImageList function, no image appears (duh). Any ideas....TIA b This article describes a CListCtrl extensi...

business/membership card, diffent names on each?
I created a membership card using the page setup for a business card. Is their a way to easily place a different name on each card. It is set up for a sheet of 10. I would not mind typing each name in separatly. Or is their a way to open the entire sheet of labels and type each name in individually? Compared to having publisher, just show the one card? thanks Bruce You could setup a data base or list and merge the names. http://office.microsoft.com/en-us/publisher/CH062524751033.aspx What version Publisher are you using? The above link is 2003 merge help. It is about the same in 2007...

how to copy or move controls between forms or from form to Tab con
I am trying to set up a more user friendly user interface for my database. I have a main "switchboard" that opens on startup with buttons that open other Sub "switchboards" based on subjects with more buttons to do stuff like open reports, run queries Ect.. Ive ended up with a mess of these "switchboard" forms and all of this me!close and Visible=false stuff to manage them and my users are rightfully confused if menus just dissappear without the classic IE "Back" Button.. so i would like to migrate to a tabbed control on my main "s...

Object variable or With block variable not set
I'm trying to put a command button on a form using the command button wizard and I am getting this message "Object variable or With block variable not set". I cannot figure out what's happening. I tried opening different instances of Access and am getting the same problem with some but not all of my .mdb files. Hope someone can help. Thanks, Laura Laura Its hard to think what it would be with no example... did you edit the code generated by the wizard? or is it the wizard producing the error? Can you paste the code here? cheers Jeff "laura" <replyto@gr...

Access Control variable values in one PropertyPg from another Pro
hi all, i am unable to access the property page control values from another property page. // snippet of the code CPropertySheet dlg(_T("Hellow"), this, 0); one a; //First Property Page two b; //second Property Page three c; //third Property Page dlg.AddPage(&a); dlg.AddPage(&b); dlg.AddPage(&c); dlg.SetWizardMode(); dlg.DoModal(); //================================================ if the first property page contains the ComboBox with some values i am trying to acces the values in the second property page as one* m_Main2 = (one *) GetParent(); CString str; fo...

define range using col and row names; not cell name
How do you set a range using these four names? They define whole rows and columns. The first column and row, along with the last column and row, define a range first_data_col last_data_col first_data_row last_data_row I can select columns with, as an example: mySheet.Range(mySheet.Range("first_data_col"), mySheet.Range("last_data_col")).EntireColumn.Hidden =3D False I'm trying to do a sort, but I have to define the range to sort, as in ws.Range("D7:L25"), but I don't have cell names, I have 4 whole row and column names ( such as ...

Recordset in excel with variables
I have successfully figured out how to retrieve data from a SQL server from within an excel sheet. The thing I can figure out is how I can use variables in that recordset from data in a particular cell. Example : Select * from inventoryAudit *that works currently in my sheet but I need to add a variable to the query Example : Select * from inventoryAudit Where transfer_dte Between varStart And varEnd * varStart & varEnd would be dates entered into 2 cells on the sheet, than a button would be pushed that would run the query and return the results into the sheet This is what I have...

Variable instances
Hi, I just want to check that i have the correct understanding of the following premise. I have a Class , say Class A that i use as a base class for two other classes, say Class B and Class C. I declare instance sof each class as follows. ClassB p_BVar = new ClassB( ); ClassC p_CVar = new ClassC ( ); Each class inherits a member variable from the Base Class called bool bStatus; Now if i change this variable using p_BVar->bStaus = .... this change should not be relected in p_CVar since p_BVar and p_CVar are two separate instances and do not point to the same address. Is this a corr...

how to convert a CString variable to unsigned short array one?
Hi, In my unicode VC6 app, how to convert a CString variable to unsigned short array? ....... CString strRst; unsigned short strOleChars[100]; strOleChars = strRst; //??? Thank you. Is ConvertStringToBSTR() what you are looking for? AliR. "David" <David_Wang_Xian@hotmail.com> wrote in message news:e6gbA3avFHA.720@TK2MSFTNGP15.phx.gbl... > Hi, > In my unicode VC6 app, how to convert a CString variable to unsigned short > array? > ...... > CString strRst; > unsigned short strOleChars[100]; > strOleChars = strRst; //??? > > Thank you. > > ...

data validation not enforced with a named range source excel 2002 sp2
I have a cell with the following data validation settings that still allows any cell value inspite of the validation. The drop down list works, but is not enforced. How can I enforce this validation? Settings: Allow=List Ignore Blank=Yes In-cell dropdown=Yes Source="=Comment" (Comment is a named range) Input Message: Show message...=Yes Title and message entered. Error Alert: Show alert...=Yes Style=Stop Title and message entered. Source should be =Comment I don't know if that is what you have? -- Regards, Peo Sjoblom (No private emails please, for everyone'...

word cannot save due to naming or permission error
Users trying to save office documents via AFP to a win2k3 server. I've read some info on this from back around the first of the year but want to know if the bug has been fixed. Mac OSX hints says to do this: $ cd /path/to/volume/or/sharepoint $ sudo mkdir .TemporaryItems $ chgrp staff .TemporaryItems $ chmod 1770 .TemporaryItems but the .TemporaryItems directory already exists on the server share.Is there any other solution?Thanks, On 2006-07-25 17:10:04 -0500, "rockymtn" <sschaefer@forethought.net> said: > already exists on the server share.Is there any other...

NDR Sender name
Hi, We have Exchange 2003. I have added my email address to receive a copy of each NDR. It tells me who the intended recipient is but not who has sent the message. It would be handy for important messages to contact the sender to advise them that the address they used is not correct. I know they will get a NDR themselves, but sometimes a direct contact works better. Is this possible at all? John On Tue, 29 Aug 2006 11:57:27 +1000, "John" <john_corangamite@hotmail.com> wrote: >Hi, > >We have Exchange 2003. I have added my email address to receive a copy of ...

Referencing Variable Name Worksheets
I'm updating a formatted worksheet every day. I have a macro that processes, lets the user augment, and then saves that days data into a new worksheet with that days date. I need to reference that worksheet the next business day to error check. I cannot : PREVIOUS DATE IS IN CELL A1 s = range("a1").value worksheets(s).select Thank you for any help/suggestions Chris Cameron You might try sheets(1) sheet1 -- Don Guillett SalesAid Software donaldb@281.com "camerons" <camerons@epud.net> wrote in message news:117nvk3b9e8mg06@c...

Pop up for user name and password
This is message I keep getting I do have McAfee security and I have already turned off email scanning what else can I do completely uninstall anti-virus? Account: 'pop.hollandpaving.net', Server: 'pop.hollandpaving.net', Protocol: POP3, Server Response: '-ERR Logon Failure', Port: 110, Secure(SSL): No, Server Error: 0x800CCC90, Error Number: 0x800CCC92 did you ever get an answer to your question? "Holland" wrote: > This is message I keep getting I do have McAfee security and I have already > turned off email scanning what else can I...

Removing CEdit controls from CDialog!
I am creating texboxes at runtime and placing it on a CDialog the CEdit objects are stored in a CObArray and used in later point of reference. As I am creating textboxes at runtime i want to remove the controls from the CDialog at runtime. For e.g., When a button is clicked 10 textboxes are displayed and in another button click i want the textboxes to be removed from the CDialog. Please guide me how to acheive it. Do you want to destroy the edit boxes or just hide them? "Iyappan" <iyappanekp@hotmail.com> wrote in message news:050901c370e4$f49a4070$a101280a@phx.gbl... ...

typed variables
I just now noticed there is a big difference in coding $i = [int] 9.99 and [int] $i = 9.99 PS C:> $i = [int] 9.99 PS C:> $i 10 PS C:> $i = 9.99 PS C:> $i 9.99 PS C:> [int] $i = 9.99 PS C:> $i 10 PS C:> $i = 9.99 PS C:> $i 10 How would I take away the type binding from $i without deleting the variable once I associate a type with it? - Larry you can change the type [double]$i = 9.99 Typing as an integer and then giving it a non-integer value could cause issues with your logic -- Ric...