Iterate Class Propertied To Get Their Names?
Mar 17, 2009
I have the following class that i use to pull data from a API.here is my callDim myProducts As clsMagentoProduct() = clsMagentoProduct.List(apiURL, sessionId,New Object() {filterOn})
View 2 Replies
ADVERTISEMENT
Sep 1, 2009
I'm trying to create an export Excel/CSV function that will iterate through a custom object and first output the property names and then output the values. I want to use reflection only where necessary so I'm attempting to save the property names when I output the headers and then reuse them to print the values. Is this possible? I'm a little weary of using reflection in a loop but is there a better way?
[Code]...
View 2 Replies
Jan 29, 2009
I need to iterate through controls using dynamic construction of control names and it looks like this could be what I need, however I never used this before and it does not quite work. What am I doing wrong? GroupBox1 is what I am attempting
Dim x as Integer = 1 For Each ctrl As Control In CallByName(Me, "GroupBox" & CStr(x), CallType.Method).Controls The runtime error is "GroupBox1" not found on Form1 even though I can select Me.GroupBox1 from the dropdown list.
View 14 Replies
Aug 24, 2010
I have an application and Spy++ reports that the parent window has many controls that are hidden. When I do a mouse click on the application's window, a number appears and I suppose it's the hidden controls that change their text/picture.So, is there a way to iterate the parents hidden controls names, get their handles and then activate them one by one (with sendmessage/postmessage wm_buttonclick) to see what changes?Right now I get the windows handle with FindWindow and the window's process id.
View 5 Replies
Feb 15, 2011
I have a class that hosts inside other classes that can host otherclases as well and so on.
I want to change the value of one property (PropertyA) in all classes down the tree.
How can i do that when i dont know the the type of class inside?
How can i iterate through the classes hostes as proeprty of the mother class?
I am trying to use reflection but i get just the properties of the first class
View 1 Replies
Dec 18, 2009
What i'm trying to do:
I've got a library which includes a class:
Class Human
End Class
and another class which refers to the human class
Class ASD
Private somevar as new Human
End Class
Ok now i've got a problem, i wish to rename my class Human, to Man. i've got to change Human to Man 2 times, which is OK but the problem is that in the real case, its not just 2 times, its like 500 times or more.
Well its something like a PHP on Javascript.
the following shows the solution of what i'm trying to do, but its in another language PHP/Javascript:
note: in php $ sign declares a variable, echo writes the variable out
CODE:
Is there anyway to do that with VB?
View 6 Replies
Dec 15, 2011
I'd like to have something like:
[Code]...
View 1 Replies
Mar 29, 2009
When you create a new asp.net page in VS 2008 and choose code behind, it also creates the typical aspx.vb or aspx.cs file to go along with it.
At the top of those files, VS names the 'Partial Class' name the file structure and/or name of the aspx file.
The question: Is there a best practice for this? Can I just use a single class name for all the pages in my application or perhaps a single directory instead of having to give each one a unique name?
View 5 Replies
Jan 11, 2012
I have got a class which contains more then 160 fields. i need the name of fields (not value) in an array. get loop through names for field or get list of field names in a array so that i can loop over it and use it in code. i am using visual studio 2010
View 2 Replies
Sep 5, 2010
1. create a blank VS2010 web project called "MySite" targeted at 4.0
2. create a new class object, calling it "class1.vb" (cause it's so unique!!)
3. change default code to read as such...
Namespace MySite
Public Class Functions
Public Shared Function WhatIsTodaysDate() As String
Return Date.Now.ToLongDateString
[code]....
Why is VS asking me to call the namespace twice if I use the "Imports" directive?I'm sure this has got something to do with VS2010 and the 4.0 framework.
View 2 Replies
Jan 9, 2009
Trying to understand the best way to do this and I'm can't get it figured. Here's basically what I have:
Public Class CardParsingClass
Private iAcctIDStart as integer
Private iAcctIDLength as integer
[code]....
I've only included 2 of the class level fields here but there are actually 30, so that's why I was hoping to be able to send the name of the field to set and the value to set it at in the SetValue function. So in some other routine in the program I'd like to be able to issue the following call:
SetValue("iAcctIDStart", "3")
But then when I get into the SetValue routine, I'm not sure how to proceed. I thought about a case statement that would basically be this:
select Case strFieldToSet
case "iAcctIDStart"
iAcctIDStart = cint(strValue)
[code]....
View 5 Replies
Mar 6, 2009
Okay, say I have a class named "ChannelList", and it raises an event named "FoundChannel"
But what I'M wanting to do is create multiple classes of different names that use that class, but I want to have all of the "FoundChannel" events be handled under one single sub routine?
View 15 Replies
Dec 9, 2011
I have a class with many properties to which I need to assign values.I have another class with a sorted list of data from which the assignments are to be made. Is there a way to get the names properties from a class and refer to those properties?I looked through System.Reflection.Assembly but could not find a way to do it.
Class DataMngr
Sub ManageData()
Dim sl As SortedList(Of String, Double)
sl = GetData()
[code]....
View 4 Replies
Nov 17, 2009
I'm quite new to Visual Basic - using Visual Studio 2008 and can't seem to find a way to do the following:
I have a few tables in a SQL Server database and have used LINQ to SQL to create classes of those tables.
Here's a cut down example of what I'd like:listbox1 filled with table names - APS, SMPS, WCPC, CFLAPS
Then from the SelectedIndexChanged event, listbox2 should populate column headers of the selected table.
I have no issues getting data from the database, and can access all of these headers through the anonymous type objects created from a LINQ query (eg APS.ID, APS.count etc), but populating a listbox with these variable names rather than the data inside them seems rather elusive.
This is probably a cross platform coding question rather than VB specific, so if you have a solution in C# or whatever I'd be happy if you could let me know.
View 2 Replies
Jun 21, 2010
I have valued pairs, attributes names and values in one hand, and I have an object with attributes. I need to set the values of those attributes. I need something like [code]
View 1 Replies
Feb 1, 2011
I am working on a project where my class has to execute VB code provided by the user, to make it simple I am trying to recreate my own eval function, I am using the following code I found on the web to do this task.
Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection
[Code] .....
The problem with code is that it can't access any variables or there values, so I have decided to get the variable names, there values types and there types dynamically and recreate them in the class that is being created dynamically. Any way to get the variable names there types and values in the current class or method, so that I can recreate them, and execute the user passed code, the user knows what variables are in the current class or method and there datatypes but he don't know there values as they may have changed, so he can't initialize them. Is there a way to do this, this code will be called in an asp.net page on page_load event, the code passed by the user is stored in the variable vbCode that is passed as a parameter.
View 2 Replies
Feb 24, 2009
I want to create a class (I think) that has properties that correspond to column names in a database table, such that they come up in Intellisense when I type the dot after the class name. Is this possible to do?
View 5 Replies
Feb 3, 2012
I'm using SharpDevelop and .NET 4.0.
My question is this: If you start a new project with a "Windows Application" template, it generates a Program.vb with the following contents[code]...
View 1 Replies
Aug 15, 2011
I have a DataGridView which populates from an SQL query just fine in default mode
using these table names
[firstName] [varchar](20) NOT NULL,
[lastName] [varchar](20) NOT NULL,
[code]....
I have edited the column headers and set the column names to the same values as my table names yet the data is not showing in form load I have set datagridview.AutoGenerateColumns = False I know the data is there if I delete datagridview.AutoGenerateColumns = False then the data is shown with the default headings?
View 3 Replies
Nov 9, 2005
I made project using VB.Net 2005 with multi languages, the first form is MDIParent form with MainMenu and toolbars also there is some changes in properties as righttoleft and text of forms.In my Mainmenu (Menustrip) there is opetion to change the UI Culture and I have already done but I need to change all texts in the form as mainmenu items anf form properties.My quetion is: how can I reload my form again to read the new texts names and mainmenu items names from resx file?
View 8 Replies
Sep 5, 2011
I am doing work for a client who has lost the source code for one of their VB.Net WinForms applications. The assembly they have is not obfuscated at all. I am trying to recover as much of the source as I can as C# source and have tried several tools for decompiling assemblies, including Reflector, ILSpy and JustDecompile (all the latest versions), but they all produce code with a huge number of errors in them. Because of the large number of errors in the generated code, I am going to ask about the specific errors (in different questions), get more directed answers and in this way try shed some light on why all the tools are having difficulty decompiling this assembly. This question pertains to the fact that the code generated by all these tools always have a large number of invalid member variables (fields) such as the following:
private short $STATIC$Report_Print$20211C1280B1$nHeight;
private ArrayList $STATIC$Report_Print$20211C1280B1$oColumnLefts;
private StaticLocalInitFlag $STATIC$Report_Print$20211C1280B1$oColumnLefts$Init;
why the generated code has these invalid member variables?
View 3 Replies
Oct 31, 2010
Is there any way to get common control names like Save, Copy or Undo Redo in the user's windows language? (I saw this in some programs which weren't made for my windows language. Also the Yes No Massage Boxes will change...)
View 1 Replies
May 25, 2006
I am experiencing a problem when trying to convert a rather large VB6 application into a .Net 2005 application. Everytime I try to convert the project I get the following error: "Upgrade Failed: Exception occurred: Can't use character device names in file names"The weird thing is i have tried to convert the project using .Net 2003 and I do not get the error, it does convert.
View 12 Replies
Jan 27, 2012
I'm using a DynamicJsonModelBinder from a blog post to pass my JSON data from JavaScript to my ASP.NET MVC Controller as a DynamicJsonObject.
Have a look at the blog post: [URL]
I converted it for my project to VB.NET : [URL]
Imports System.Dynamic
Imports System.Web.Helpers
Namespace MyNameSpace
[Code]....
This works. In my controller, I can access my jsonObject like this: obj.ID '123
But I haven't got an idea yet how to iterate through all properties. I can get all member names as a IEnumerable String Collection (obj.GetDynamicMemberNames()), but how do I use the TryGetMember method to access the value of a member ?
View 1 Replies
Aug 15, 2011
I have a VB Web Application with a bunch of textboxes on it in Default.aspx (Using the basic template in Visual Web Designer 2010 Express). I'd like to iterate through those textboxes using some sort of VB solution if at all possible and clear them when the user presses a button. I've tried using something like this:
Dim cControl As Control
For Each cControl in Me.Controls
If cControl Is TextBox Then
[Code].....
View 3 Replies
Jul 7, 2010
[This is a simplified example] I have a collection ("myCollection") in which exists three entries: ("hello", "goodbye", "welcome"). I want to iterate through the collection and if in the collection there is the entry "welcome" I want to take one action, if that entry doesn't exist I want to do something else. Like this (pseudo):
[Code]...
View 1 Replies
Jan 15, 2010
I need some help with a LINQ query in VB.Net, please.[code]This works, and returns me the data I need to work with. Now I want to iterate through the groups, using a For Each construct. like this: For Each x In drivers Next...However, the compiler is barking at me, telling me that the "'x' is not accessible in this context because it is 'Friend'."
View 3 Replies
May 19, 2011
I have a simple XAML file with a grid in it and textboxes. But when using my code it does not find the textboxes by iteration.
VB.Net:
Dim ctl As FrameworkElement = Me.MainWindow
Code:
Dim ChildrenCount As Integer = VisualTreeHelper.GetChildrenCount(ctl)
'ChildrenCount is always zero
For i As Integer = 0 To ChildrenCount - 1
Dim Child As FrameworkElement = VisualTreeHelper.GetChild(ctl, i)
[Code].....
View 3 Replies
Jan 31, 2010
I have a BindingSource bound to a DataTable.
I use the BS Filter and would like to iterate the filtered dataset of the DataTable using the Bindingsource.
I know I can do a MoveFirst and the MoveNext and each time using the BS.Position get the correct row in the underlying DataTable. But how do I know when the sets ends? I'm sure there must be such a property, but what is it?
View 2 Replies
Nov 27, 2010
if I run the following code,For each itm in MyList Next if the list is nothing i got an error..Is there a better way to deal with list=nothing than using a condion like [code]
View 14 Replies