473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Creating Textboxes During Runtime.

2 New Member
Hello,

I am designing a program using Visual Basic 2005 Express Edition that will ask the user for a number between 1 and 50.

When the button on the form is clicked, another form (Form2) opens and the number is passed to Form2.

If the user inputs "20" in the first form, I need 20 textboxes to appear in a column in Form2.

If the user inputs 10, I need 10 textboxes and so on....

What I need help with is coding for the correct number of textboxes in Form2.

Any and all help will be appreciated.

Thanks.
Dec 31 '06 #1
4 1463
willakawill
1,646 Top Contributor
Hello,

I am designing a program using Visual Basic 2005 Express Edition that will ask the user for a number between 1 and 50.

When the button on the form is clicked, another form (Form2) opens and the number is passed to Form2.

If the user inputs "20" in the first form, I need 20 textboxes to appear in a column in Form2.

If the user inputs 10, I need 10 textboxes and so on....

What I need help with is coding for the correct number of textboxes in Form2.

Any and all help will be appreciated.

Thanks.
Hi. With the version of vb that you are using there is a problem with this approach. vb.NET does not support control arrays and a control array is exactly what you need for your project. Otherwise the coding will be cumbersome and bulky.

Do a google search for vb.NET control array

good luck
Dec 31 '06 #2
Killer42
8,435 Recognized Expert Expert
...vb.NET does not support control arrays and a control array is exactly what you need ...
Damn! MS were really keen to get rid of control arrays, huh. I wonder why, when they are so amazingly useful.
Jan 2 '07 #3
Ben3eeE
8 New Member
I actually found some MS(i think) example code called "Controlarraysa truntime"
and since iam new to programming i dont really understand everything here.

Expand|Select|Wrap|Line Numbers
  1.     Dim MynewPos As New Point(50, 40)
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim pnt As New Point(CType(TextBox2.Text, Integer), CType(TextBox3.Text, Integer))
  5.  
  6.         CreateThem(CType(TextBox1.Text, Integer), pnt)
  7.     End Sub
  8.  
  9.     Public Sub CreateThem(ByVal NumbOfPix As Integer, ByRef mypt As Point)
  10.         MynewPos = mypt
  11.  
  12.         Dim i As Integer
  13.         If NumbOfPix = 0 Then
  14.             Exit Sub
  15.         End If
  16.  
  17.         For i = 0 To NumbOfPix - 1
  18.             Dim PIC As New System.Windows.Forms.PictureBox
  19.             PIC.Size = New System.Drawing.Size(20, 20)
  20.             PIC.Location = MynewPos
  21.             PIC.Name = "PictureBox"
  22.             PIC.BackColor = System.Drawing.Color.Black
  23.             PIC.Text = i
  24.             PIC.ForeColor = Color.Black
  25.             MynewPos.Y += 30
  26.             Me.Controls.Add(PIC)
  27.         Next
  28.     End Sub
  29. End Class
  30.  
Jan 2 '07 #4
rseanbarnes
2 New Member
Thanks everyone.

Sean
Jan 8 '07 #5

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

Similar topics

8
5463
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
23
3260
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
1
3081
by: rp | last post by:
Hi, How would I create runtime tabpages with runtime controls(textBoxes,comboBox, checkedListBox), inserting,deleting, and modifing the tabpages whenever I want to in C#? Thanks in advance. rp
3
2997
by: Newbie | last post by:
hi! i am able to upload files successfully. but i have one minor problem. files are uploaded correctly if the directory exists, it is throwing an exception if the directory doesnt exist. but the directory name is created during runtime. is there a way to create a directory during runtime? exception: Error saving file C:\temp\188\ System.IO.DirectoryNotFoundException: Could not find a part of the path
2
2893
by: Anand Sagar | last post by:
I have a Panel1 and button1 on my webform. At runtime, I create 2 textboxes. I do it at the Page_Load event. I put the code within the " If Not isPostBack" For the button click event, I will do a post-to-database coding and then show the same page again. I put EnableViewState = True for the textboxes. In the Page_Load if I dont use the IsPostBack checking, the code works fine. The button shows that the code has been fired and the page...
5
1902
by: Praveen | last post by:
I have script files embedded as resources in my dll. During runtime, I would like to write it out into the app dir (or a app sub-dir) and send the appropriate virtual path to the client. This makes deploying my dll much easier - just a single dll, not having to worry about deploying script files. However, the runtime doesn't seem have enough permissions to write out to the app dir (or any of it's subdir), by default. The folder where I...
1
1951
by: Kum | last post by:
Hi, I need help in asp.net dynamic textbox controls validation. I am creating textbox controls dynamically on a asp.net webpage. Now after creating the textboxes on the page I want to validate these text boxes when the user submits or posts back to the server. My intention was to create a textboxvalidator function which takes the control name as argument and returns an true if
5
1426
by: David S. Zuza | last post by:
Hey, I am new to .NET and I would like to index a button control on my form just like I used to be able to in VB6. In VB6 all I had to do was create one control and new to something like cmdButton() and then I could copy it in the design window and refer to anyone of the buttons by refencing its index like
12
3153
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without restarting the application. What I did was to create an AppDomain that loaded the plugins and everything was great, until I tried to pass something else that strings between the domains...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.