|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hello,
I'm new to VB programming and would like to know if/how I can change the Name of a TextBox. Example: I want to change TextBox195 to TextBox196. If that is not possible, can I use a variable such as. Example: TextBox195 = TextBox195+1 < which would be TextBox196 I hope my question is not too stupid. Thanks Art |
|
#2
|
|||
|
|||
|
You can always change the name of a control using the VB IDE. From code? I'm not sure that you can change the name of a control on the fly.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Thanks for the response.
I think I've asked the wrong question for the wrong reason at the wrong time. I should have said that I want to be able to access text/value that is located in TextBox195 then access text/value in TextBox196 I suppose it would kind of be a For And Next loop reading variables. Example: For x=195 to 199: a$(x) = TextBox(x) :next x |
|
#4
|
|||
|
|||
|
If your textboxes are in a control array you can do the code you posted, but if each textbox has a different name you'll have to jump through some hoops to get to the control you desire.
You can use vbscript to build an executable line of code in code, and then execute it, but you'll have to be very careful to get this to operate with your vb variables and objects. I believe you can use the Script control to do what you want, otherwise you'll need to use the correct control name in your code. You can iterate through all the controls on a form without knowing the name, and match the name against some code, like: Code:
for each ctrl in Form.Controls debug.print ctrl.name next Last edited by Doug G : November 20th, 2004 at 12:21 AM. |
|
#5
|
|||
|
|||
|
Thanks. I think I'll change the program layout and just use cells in the excel application for data storage.
|
|
#6
|
|||
|
|||
|
You might hang loose and see if anyone else has suggestions, there are a lot of people here that know a lot more about VB than I do
![]() |
|
#7
|
|||
|
|||
|
Hi! I'm not really sure if I understood you. But we could use Doug G's code... Here goes:
Dim x as integer Dim Icontrol as control For x=195 to 199 For each Icontrol in Controls if typeof Icontrol is Textbox then if Icontrol.Name = "Textbox" & Str(x) then 'Insert ur code here. 'U cud access the value of the textbox by this: ' <Icontrol.Text> 'The name of the textbox would increment 'through each passing loop 'textbox195,Textbox196 etc... End If End if Next Icontrol Next x Hope this is cool!!! Just Be Demystify |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Change Name of TextBox or ref. to it. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|