473,379 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Help with Creating Textboxes During Runtime.

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 1456
willakawill
1,646 1GB
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 Expert 8TB
...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
I actually found some MS(i think) example code called "Controlarraysatruntime"
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
Thanks everyone.

Sean
Jan 8 '07 #5

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

Similar topics

8
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 -------------------------------------------------------------------------------- ...
23
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...
1
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
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...
2
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...
5
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...
1
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...
5
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 ...
12
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.