Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old November 18th, 2004, 03:43 PM
ImRedWhiteBlue ImRedWhiteBlue is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 ImRedWhiteBlue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Change Name of TextBox or ref. to it.

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

Reply With Quote
  #2  
Old November 18th, 2004, 04:37 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 31 m 41 sec
Reputation Power: 180
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

Reply With Quote
  #3  
Old November 18th, 2004, 04:46 PM
ImRedWhiteBlue ImRedWhiteBlue is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 ImRedWhiteBlue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old November 18th, 2004, 07:20 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 31 m 41 sec
Reputation Power: 180
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.

Reply With Quote
  #5  
Old November 18th, 2004, 08:57 PM
ImRedWhiteBlue ImRedWhiteBlue is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 ImRedWhiteBlue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks. I think I'll change the program layout and just use cells in the excel application for data storage.

Reply With Quote
  #6  
Old November 18th, 2004, 09:44 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 31 m 41 sec
Reputation Power: 180
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

Reply With Quote
  #7  
Old November 19th, 2004, 10:48 AM
demystify demystify is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 6 demystify User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Change Name of TextBox or ref. to it.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway