shagpile
07-14-2005, 08:23 AM
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
VisuallyImpared
07-14-2005, 08:34 AM
Private Sub Text1_Change()
Text2.text = text1.text
End Sub
Is this what you mean?
mkaras
07-14-2005, 08:40 AM
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.
shagpile
07-14-2005, 08:43 AM
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"
shagpile
07-14-2005, 08:48 AM
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"
grahamt
07-14-2005, 08:56 AM
You could make your Textboxes into a control array and then use the ListIndex Property of cboQuestion to get the value in the Textbox.
Private Sub cboQuestion_Click()
If cboQuestion.ListIndex > -1 Then
Text1.Text = Text2(cboQuestion.Listindex).Text
End If
End Sub
shagpile
07-14-2005, 09:59 AM
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
Bart1123
07-14-2005, 10:52 AM
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
TeraBlight
07-14-2005, 02:02 PM
Regarding the original question, there IS a really simple way of doing this, owing to the Controls collection that each form supplies:
Text1.Text = Text2.Name
Me.Controls(Text1.Text).Text = "Anything"