473,473 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how can i make textbox(n).text, how can i control n to write something in there

2 New Member
Guys! Please help me! For example, i have a programme. There are 4 textboxes and 1 button. So i write in the first textbox a number 2, 3 or 4 and then in one of the textbox programme writes something (doesn't matter what):

Expand|Select|Wrap|Line Numbers
  1. Dim x As Integer
  2.  
  3. Sub Button1.Click(....)
  4. x = Val(TextBox1.Text)
  5. TextBox(x).Text = "blahblahblah"
  6. End Sub
I hope i wrote it clear and you understand what i want - i want to control with this "x" in which textbox will i write something, but obviously my code isn't working. Please help!
Oct 25 '14 #1
3 1345
iam_clint
1,208 Recognized Expert Top Contributor
Assuming you named the controls and know what they are you can simply use the name of the textbox control to modify the value.

If I assume you don't have the names of the textboxes because they are dynamic you can iterate the controls.
Expand|Select|Wrap|Line Numbers
  1.  For Each ctrl as control In form1.Controls
  2.    If (ctrl.GetType() Is GetType(TextBox)) Then
  3.       ctrl.text="blahblahblah"
  4.    end if
  5.  Next
  6.  
But thirdly if the controls are dynamic you can store references to them in an array when you create them and then modify them that way.
Oct 26 '14 #2
SizOff
2 New Member
Sorry, i didn't get your message fully (because i don't know english perfectly, yeah), but as I understood you're trying to say that i need to use "If". I tried to do it, and, well, it works, but i use to many code on that:

Expand|Select|Wrap|Line Numbers
  1. x = Val(TextBox1.Text)
  2. if x = 2 Then TextBox2.Text = "blahblahblah"
  3. if x = 3 Then TextBox3.Text = "blahblahblah"
  4. if x = 4 Then TextBox4.Text = "blahblahblah"
So I don't like this version and want just to make like "TextBox(x).Text" without "If" or "For", but I don't know how to do it.

Or maybe I just understood you wrong.
Oct 27 '14 #3
iam_clint
1,208 Recognized Expert Top Contributor
the for loop I posted is probably going to be you're easiest solution. either that or create an array containing references to the textboxes you want.

I mean if you really wanted TextBox(i).text
Expand|Select|Wrap|Line Numbers
  1.     Dim TextBox As New List(Of TextBox)
  2.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  3.         For Each ctrl As Control In Me.Controls
  4.             If (ctrl.GetType() Is GetType(TextBox)) Then
  5.                 TextBox.Add(ctrl)
  6.             End If
  7.         Next
  8.         TextBox(1).Text = "test"
  9.     End Sub
  10.  
Oct 28 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Eric B | last post by:
I am looking for a text control (or API) that can emulate the behavior of CodeWrite where you can move the cursor in any direction on a blank text area and begin typing (so you are not confined to...
8
by: none | last post by:
Hi, I wrote a program for work that processed and formatted some collected text data in a Tkinter based GUI display. I've found that as my data files get longer (a few thousand lines), there...
0
by: NancyASAP | last post by:
In case anyone hasn't seen this problem, just sharing the info.... I created a dotnet 1.1 page with a literal control. I used a streamreader to open a text file to fill the control. I filled the...
2
by: Gwin | last post by:
I am programming a client service dbase in access 2000 for a non-profit health clinic. I want to create a navigation menu that can show varying numbers of command buttons with varying captions,...
2
by: Mark Allison | last post by:
Hi, On my Windows Form I have a text control and a button. The text control is single-line and I want the user to be able to type something in it, but when they hit Enter, I want this to click...
4
by: David Davis | last post by:
Woll2Woll has a product for Delphi called Infopower which has a rtf control with a built-in word processor. Does anyone know of a third party control that has the same capabilities. I don't have...
2
by: tlyczko | last post by:
Hello, I'm experimenting with Stephen Lebans' Rich Text Control for doing RTF data entry into a memo field. I imported the table, form, toobar, and modules from the A2k version into an A2k3...
1
by: (PeteCresswell) | last post by:
Got a text control that where .Locked = True. I have the text blue and underlined to simulate a clickable link on a web page. If the user clicks on that field, I open up a window that shows the...
1
by: ozzy66 | last post by:
Hiho NG, I've created a tool (tray application) like "keytext" or "shortcut" that is a little tool where you can store text components which you can call from any running app. Such a stored text...
1
by: Randy Shore | last post by:
I have run into a problem with the new rich text control in Access 2007. It seems that you can only choose from 6 preset font sizes when entering or editing text. The sizes are...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.