Refer To An Object By Its Name?
Jun 18, 2012
Is there a possible way to refer an object through it's name in Vb.Net?The case is, I have menu items created in my designer with names such as MenuA, MenuB and MenuC.On the database, I created a table consisting the list of all available menus in string format : MenuA, MenuB all the way to MenuZ.
Also I created a dynamic table consisting the user permission, what menu is accessible by a certain user.So when I started the app, it will get the name of menu assigned to the logged user, and start to turn the Visible property to TRUE.If it was a Control, I would just loop through it by Parent.Controls.Find(FoundMenu, True).My problem is most of it is not a control, it is an Item added to the Control, or even another SubItem added to the Item.So how can I found an object in my UI only by it's name?
SearchQuery = "SELECT menu_name FROM tbl_menulist menu, tbl_user user WHERE menu.id_menu = user.id_menu"
QueryReader = ExecuteQueryReader(SearchQuery)
QueryReader.Read()
[code]....
View 1 Replies
ADVERTISEMENT
Nov 11, 2010
I hope the question makes sense, anyways. I'm looking to know if in VB.NET, when we call an object's constructor, is there some kind of a reference that points back to the caller? I'm interested because of a corner case where I want the object being created to first be able to validate the existence of some data in the caller before it allows itself to be created. If this validation fails, I plan on throwing an exception. This corner case will never happen at runtime unless the object being created is used improperly by a programmer. The object being created is not inheriting the object I want it to validate, so I can't do anything with the MyBase qualifier.
It's bit of a "future-proofing" issue that I have a (bad) habit of doing. Not critical -- I can always leave stern comments behind as a last resort. Wanted to know if this was possible.
View 3 Replies
Dec 22, 2009
I am doing a calculator project.In the given code below I want to modify the line txtDigitPanel.Text = Trim(txtDigitPanel.Text) + "0" as txtDigitPanel.Text = Trim(txtDigitPanel.Text) + this.text (the word 'this' is taken as a reference to the object that has invoked the event ) to avoid hardcoding. Because when I copy the BtnZero, the same code will work for other digits also. Is it possible?
Private Sub BtnZero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Len(Trim(txtDigitPanel.Text)) < 15 Then
txtDigitPanel.Text = Trim(txtDigitPanel.Text) + "0"[code]....
View 3 Replies
Nov 12, 2010
Is there a way to reference an object by using the value of a string read from a text file? Here's an example of what I mean: I have a user control called 'Fish', one called 'Cats', and one called 'Dogs' and so on.... I have a text file containing this line, amongst many others in a long script written after compile time by the user:
[Code]...
View 2 Replies
Apr 15, 2012
after searching on the web, i know that Me keyword is use to Refer to the Current Instance of an Object, but if i want to Refer to the others Instance of an Object, what is the keyword that i need to use?
View 4 Replies
Apr 21, 2010
I have a label testlabel. is there some way I can refer to it as:
dim t as string = "testlabel"
(something here referring to the OBJECT with the same name as the string).text = "mytext"
? I have 50 labels with text to change and would love to be able to:
for i = 1 to 50
dim t as string = "testlabel" & i
convertsomehow(t, label).text = "mytext"
next
so that this would change testlabel1, testlabel2, testlabel3, ... , testlabel50.
View 2 Replies
Jun 22, 2009
I know the name of a textbox in string format: txtbox & i. Through the loop, the txtbox name will be txtbox1, txtbox2,.... And I want to change the txtbox & 1 's text dynamically in the code. How can i refer to the textbox obj from the string?
View 9 Replies
Sep 9, 2010
I'm using win7 64bit + express 2010. in the program, I need refer to Microsoft HTML Object Library. So, I added it, then I found, it can not be "copy local". I remeber it could before when I use oit on vista + 2008.
Now, the question is: how can I include it in the setup? since some users may not have this dll on their pc.
View 2 Replies
Nov 28, 2009
I have a program that used information form treenodes and put them in the textbox after timer ticks the problem is that i should use AddHandler for ticking, but i dont know how to refer to the title() and name() because they are not on the same sub private
[Code]....
View 1 Replies
Aug 25, 2009
I am amateur programmer.so far, I can use Visual Basic .Net only. That is all I know!!How can I refer to a MessageBox?or how can I Programatically handle a MessageBox after it is displayed?I need to close a MessageBox after certain time if no response from the user.
View 3 Replies
Jan 14, 2010
Can anyone tell me looking at this picture what Value is or what it could mean/reffer to? (S-1-5-xx-xxx)I had to block out some of it since I am not sure what it means.
View 2 Replies
Aug 15, 2011
I would like to develop a VB.Net based smart device app. A simple one. Do any of u know where i can refer to samples of such apps?
View 2 Replies
Nov 18, 2011
I am creating a project using VB, and I am new to VB, I am still a beginner, I need help in retrieving email address from database when I enter the username, I have added the code below, please review it and let me know, basically when I enter the username it has pull the email address and display in the label..[code]I am stuck at the sql statement as I have no idea how to refer the text box as the username i.e "& uname" it is the name of the text box, is it the right way, also then as I informed I need to paste the email address in the label and the name is label2, I am trying it as " label2.text=da" but I get a error message, I am using Visual basic professional 2010.
View 11 Replies
Aug 18, 2010
I have a bunch of string variables, string1, string2, string3 etc.At the end of my program I want to write these strings to a file, but I don't want to have to laboriously type out string1, string2, string3 etc.
It would be much easier to use a loop to dynamically refer to (string & loopcounter), ie reference the variable by dynamically concatenating its name from a string and a number. Python can do this with eval(). How does VB do it? I can think of loads of examples where it'd be useful. Otherwise I have to type out all the different conditions and that's not efficient.
View 1 Replies
Sep 2, 2009
am making a super advanced text processor and i am at the point where i am trying to make print preview dialog [code] Word_Env.Form1' cannot refer to itself through its default instance; use 'Me' instead.i have tried "Me" but that don't work.
View 2 Replies
Aug 23, 2011
This was explained in a recent thread - but I can't find it again :-( Why won't the following work? I am trying to set the bounds on 9 buttons - Button11 to Button19. All these buttons are already added in design time. qli() is a rectangle array.
[Code]...
View 9 Replies
May 7, 2012
I am very new to programming so I apologize if I am asking really basic questions here, but how would I go about referring to a specific column in an array? I am trying to use the prices in one column of my array and multiply that by a quantity, but I am not sure how to extract the price out of the array.
[Code]...
View 4 Replies
Mar 9, 2011
I have a user control called UCO and it is being put in many diffrent forms.How can i refer to these forms from the code of the UCO?For instance, how can i get the color of the form and make the UCO have the same color?
View 1 Replies
Jan 13, 2009
Im working on a project and just wanted to know to make a control refer to itself?I know that by using the word "Me", the system refers to the form but how about the control. I know that i can simply name the control (e.g. txtSurname.Clear) but if i was to use the code on multiple controls it would save alot of time if the control could simply refer to itself!
View 7 Replies
Feb 9, 2011
I've a vb.net web application where I'm referring to another vb.net dll by adding the reference of the dll and creating the object but after the call it waits for dll to finish operation and return a value before moving forward, is there a way I can do the same job asynchronously.
View 4 Replies
Oct 8, 2010
In VB 2010, I am trying to use this query, but I always get an error message because the numerical variable CHAVE is not correctly called. STATUS and HISTORICO are string type fields, that will be filled by the string variables SITUACAO and DESCRICAO.DIA is a date type field and will be filled by the date type variable PROXIMA.CHAVE is a numerical field and should be filled by the numeric variable CHAVE.
sql = " INSERT INTO " & conta & " (status,dia,chave,historico)" & _
" VALUES ('" & situacao & "', #" & Format(proxima, "M/d/yy") & "#, & chave &, '" & descricao & "') "
View 6 Replies
Jul 8, 2009
Refer to all of one type of control?
View 2 Replies
Dec 20, 2009
How do I refer to a form in my project by using a string variable? I'm running Visual Studio 2008.My main screen has a number of dropdown menus that, when an item is selected, a form will open:
Dim Mdi_frm_Doors As New frm_Doors Mdi_frm_Doors.MdiParent =Mdi_frm_Doors.Show()In this example, I am providing the name of the form directly (frm_Doors). What I would like to do is refer to the form as a string variable.I'm already doing something similar to access specific controls on other open forms (where str_Field is the name of the control I am accessing):
[Code]...
View 1 Replies
Apr 22, 2010
I have a string called testlabel, and would like to refer to it via the string "testlabel", how do I do this?
for instance:
dim testlabel as label
dim a as string = "test"
dim b as string = "label"
'what is the line I need here? a & b.text = "hello world"
to get testlabel.text to read "hello world"?
View 1 Replies
Dec 26, 2009
Refer to many checkboxes or other controls at once?
View 8 Replies
Apr 16, 2012
I'd like to know if it is possible to refer to section of an array. e.g.
dim a(10) as integer
foo(<reference to array a starting at item 2>) 'only use items 2 to 9 of the array
...
sub foo(byref a() as integer)
<do something with array>
end sub
Note that I don't want to copy the array to a new array or pass in indices, if I can avoid doing so. Subroutine foo should be able to process the array without knowing if it gets the whole array or just a section.
View 13 Replies
Jun 27, 2009
how can i implement iextender so it adds a property to all textboxes in my project. the class that i want to implement iextender from is a usercontrol, and the property will be similar to the imagelist property in listview properties. also how would i refer to the extendee from the extender?
View 2 Replies
Jun 22, 2011
any easy way to ref c sharp programs from visual basic? Can it be referenced from within the .net program?
View 2 Replies
Mar 15, 2011
I am beginner in VB.net and want to learn socket programming suggest me some good articles to refer at beginner level
View 4 Replies
Feb 16, 2010
I have a bizarre vb.net problem.I'm working with a 3rd party library with a namespace called Telerik.Webcontrols. The library is in a web site project that I am in the process of converting to a web application project.
Telerik.WebControls contains a class called RadAjaxControl.In the original web site project, I have code that looks like this:
public sub page_load(...)
dim foo as Telerik.Webcontrols.RadAjaxControl
Once I convert to a web application project, it says that Telerik.Webcontrols doesn't exist.
However, the truly bizarre thing is that the following code does compile:
imports Telerik.WebControls public sub page_load(...)dim foo as RadAjaxControl
View 2 Replies