473,383 Members | 1,762 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,383 software developers and data experts.

creating textbox using commands

i've got this code to create a textbox using a command button but i can't understand anything of it , please can you explain what each word especially(set,prevtextcontrol,controlid) mean and what each line mean, here is the code :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Dim TextControl As TextBox
  3.     Dim PrevTextControl As TextBox
  4.     ControlID = ControlID + 1
  5.     Set TextControl = Form1.Controls.Add("Vb.TextBox", "Text" & ControlID)
  6.     If (ControlID > 1) Then
  7.         Set PrevTextControl = Form1.Controls("Text" & (ControlID - 1))
  8.     Else
  9.         Set PrevTextControl = TextControl
  10.     End If
  11.     With TextControl
  12.         .Left = (PrevTextControl.Left + PrevTextControl.Width) + 10
  13.         .Top = 20
  14.         .Width = 50
  15.         .Height = 20
  16.         .Visible = True
  17.     End With
  18. End Sub
Feb 26 '14 #1
1 1061
Each object on a form has a ControlID for use by the system. When you create a new object you have to create a new ControlID for it. Textboxes also need to know the ControlID of the previous Textbox, probably because of the Validation option.

The line that starts with set instantiates the new Textbox.
Everything after the line that starts with 'With' just sets the position of the new Textbox.
All the If End If structure is doing is getting the ControlID of the previous Textbox if there is one.
Apr 7 '14 #2

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

Similar topics

9
by: Gary | last post by:
Hello, Is it possible to dynamically update a textbox with words chosen from a list using form checkboxes and javascript? Gary
1
by: Jose Gonzalez | last post by:
How to apply a numeric format to a textbox using xhtml? I know you have to use the "-wap-input-format" style tag in css. I can get this to work in a regular xhtml page, however, I've been...
3
by: Ricardo Corsi P. Cesar | last post by:
I have many textbox in my webform, but i want clear all of them with on single step. Someone have the code ? Thks
1
by: PJ6 | last post by:
How do I select a subset of text in a textbox using JavaScript? Paul
2
by: Gautam | last post by:
ex: I have a color in RGB component say 255,0,0 ie red. now i want to set the back color of a textbox using this RGB component txtColorBox.BackColor = ?????? Any suggestions??? -Gautam
5
by: SKS | last post by:
hi all i would like to know how to restrict user from entering numeric value ina textbox..using C# if user try to enter text it shouldnt be allowed.. i tried errror provider.. but it doesnt met...
1
by: durga2005 | last post by:
hi I m validating a textbox using regular expression validator and these controls are placed inside the update panel the validation is not working inside update panel
2
arun3232
by: arun3232 | last post by:
how can i display data to textbox using sql server in asp.net with c#..
1
by: mirasol | last post by:
i am new here,i just want to ask question about uploading file with textbox using mysql and php, i used the codes given by some member and my problem is i dont know how to add textbox and i want it...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.