Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Text location in text box


Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2005, 08:23 AM
shagpile shagpile is offline
Newcomer
 
Join Date: Jul 2005
Posts: 17
Angry Text location in text box


Using VB6 Enterprise

I need to refer to a textbox

The textbox is written in another textbox
text1.text = "text2"

to put "Anything" in text2 I want to say

text1.text = "Anything"

where text1.text is the location of where is goes and not the text itself


Any help would be GREATLY appreiciated.

Thanks
Reply With Quote
  #2  
Old 07-14-2005, 08:34 AM
VisuallyImpared's Avatar
VisuallyImpared VisuallyImpared is offline
Junior Contributor
 
Join Date: Sep 2002
Location: Toronto, Canada
Posts: 278
Default

Private Sub Text1_Change()
Text2.text = text1.text
End Sub

Is this what you mean?
__________________
Win Win Situation: Swapping my salary with my golf score
Reply With Quote
  #3  
Old 07-14-2005, 08:40 AM
mkaras's Avatar
mkaras mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

Loosely speaking you are asking for the functionality of indirection wihich is typically provided for in a language by way of pointers. Visual basic does not have a pointer data type and so you cannot directly do what you wish.

However, if the program design you are working on is not too huge and the number of choices of where the text "indirectioin" that you need is limited you could try another approach. Make a global variable as an enumeration constant and give it a set of named values such as DoText1, DoText2, DoText3 that correspond to all the various controls you would like to route the text string to. Then make a sibroutine that you pass the string to. Inside this subroutine there will be a Select Case statement that uses cases going by the names of the above described enumeration values. For each case you provide the code to copy the string that was passed to the subroutine into the .Text property of the correspondiing text box.
Reply With Quote
  #4  
Old 07-14-2005, 08:43 AM
shagpile shagpile is offline
Newcomer
 
Join Date: Jul 2005
Posts: 17
Default

visually impared, thats notwhat I meant. no
mkaras, yes. Thats what I want.

I have a few textboxes though
There are twice as many as below
they are
txt1a1, txt1a2
txt1b1, txt1b2
etc

Apart from "Any"

cboQuestion.AddItem "Any"
cboQuestion.AddItem "1a"
cboQuestion.AddItem "1b"
cboQuestion.AddItem "1c"
cboQuestion.AddItem "1d"
cboQuestion.AddItem "1e"
cboQuestion.AddItem "1f"
cboQuestion.AddItem "1g"
cboQuestion.AddItem "1h"
cboQuestion.AddItem "1i"
cboQuestion.AddItem "1j"
cboQuestion.AddItem "1k"
cboQuestion.AddItem "1l"
cboQuestion.AddItem "1m"
cboQuestion.AddItem "1n"
cboQuestion.AddItem "2a"
cboQuestion.AddItem "2b"
cboQuestion.AddItem "2c"
cboQuestion.AddItem "2d"
cboQuestion.AddItem "2e"
cboQuestion.AddItem "2f"
cboQuestion.AddItem "2g"
cboQuestion.AddItem "2h"
cboQuestion.AddItem "2i"
cboQuestion.AddItem "2j"
cboQuestion.AddItem "2k"
cboQuestion.AddItem "2l"
cboQuestion.AddItem "2m"
cboQuestion.AddItem "2n"
cboQuestion.AddItem "3a"
cboQuestion.AddItem "3b"
cboQuestion.AddItem "3c"
cboQuestion.AddItem "3d"
cboQuestion.AddItem "3e"
cboQuestion.AddItem "3f"
cboQuestion.AddItem "3g"
cboQuestion.AddItem "3h"
cboQuestion.AddItem "3i"
cboQuestion.AddItem "3j"
cboQuestion.AddItem "3k"
cboQuestion.AddItem "3l"
cboQuestion.AddItem "4a"
cboQuestion.AddItem "4b"
cboQuestion.AddItem "4c"
cboQuestion.AddItem "4d"
cboQuestion.AddItem "4e"
cboQuestion.AddItem "4f"
cboQuestion.AddItem "4g"
cboQuestion.AddItem "4h"
cboQuestion.AddItem "4i"
cboQuestion.AddItem "4j"
cboQuestion.AddItem "4k"
cboQuestion.AddItem "4l"
cboQuestion.AddItem "4m"
cboQuestion.AddItem "4n"
cboQuestion.AddItem "4o"
cboQuestion.AddItem "4p"
cboQuestion.AddItem "4q"
cboQuestion.AddItem "4r"
cboQuestion.AddItem "4s"
cboQuestion.AddItem "4t"
cboQuestion.AddItem "4u"
cboQuestion.AddItem "5a"
cboQuestion.AddItem "5b"
cboQuestion.AddItem "5c"
cboQuestion.AddItem "5d"
cboQuestion.AddItem "5e"
cboQuestion.AddItem "5f"
cboQuestion.AddItem "5g"
cboQuestion.AddItem "5h"
cboQuestion.AddItem "5i"
cboQuestion.AddItem "5j"
cboQuestion.AddItem "5k"
cboQuestion.AddItem "5l"
cboQuestion.AddItem "5m"
cboQuestion.AddItem "5n"
cboQuestion.AddItem "5o"
cboQuestion.AddItem "5p"
cboQuestion.AddItem "5q"
cboQuestion.AddItem "5r"
cboQuestion.Text = "Any"
Reply With Quote
  #5  
Old 07-14-2005, 08:48 AM
shagpile shagpile is offline
Newcomer
 
Join Date: Jul 2005
Posts: 17
Default

I am trying to refer to textboxes to query a database in a round about kinda way. The rest is all done and this is the last section.

How to choose a textbox to find out if it contains "Yes", "no" or "Left blank"
Reply With Quote
  #6  
Old 07-14-2005, 08:56 AM
grahamt grahamt is offline
Junior Contributor
 
Join Date: Feb 2005
Posts: 247
Default

You could make your Textboxes into a control array and then use the ListIndex Property of cboQuestion to get the value in the Textbox.

Code:
Private Sub cboQuestion_Click() If cboQuestion.ListIndex > -1 Then Text1.Text = Text2(cboQuestion.Listindex).Text End If End Sub
Reply With Quote
  #7  
Old 07-14-2005, 09:59 AM
shagpile shagpile is offline
Newcomer
 
Join Date: Jul 2005
Posts: 17
Default

Thanks for the help but I have made an executive decision to finish the project there. If they want queries they can do their own in access. Its a huge program and they have already got their moneys worth.

New question though, why cant I run the exe on other computers from a flash pen when all that is in the folder are the single exe and the MDB.

The error is "object variable or with object variable not set"
I am running winME and dad is ok XP. Though this shouldnt make a difference should it?


Using an ADODC the line already says
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Community Survey Database.mdb;Persist Security Info=False

and not

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\windows\desktop\Community Survey Database.mdb;Persist Security Info=False

Works perfectly on my machine. Just not on my dads
Reply With Quote
  #8  
Old 07-14-2005, 10:52 AM
Bart1123 Bart1123 is offline
Contributor
 
Join Date: Mar 2003
Location: Oklahoma City, OK
Posts: 455
Default

Wouldn't you need to add APP.Path to your connection string? Or does the app know to look at the directory where it is located on its own. Also does the target machine have the same MDAC as the development machine. Shouldn't make a difference, but ya never know.

Hope this helps
Bart
__________________
"I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison
Want a Gmail Account? Forum Members only please. Email me with your forum nick :)
Reply With Quote
  #9  
Old 07-14-2005, 02:02 PM
TeraBlight's Avatar
TeraBlight TeraBlight is offline
Captain Convoluted

* Expert *
 
Join Date: Jun 2005
Posts: 1,918
Default

Regarding the original question, there IS a really simple way of doing this, owing to the Controls collection that each form supplies:
Code:
Text1.Text = Text2.Name Me.Controls(Text1.Text).Text = "Anything"
__________________
"To learn without thinking is to labour in vain" - Confucius
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->