"otherObject" Is Another Variable Containing An Instance Of MyClass?
Feb 5, 2011
If I do this: Dim w As MyClass = otherObject. where "otherObject" is another variable containing an instance of MyClass, I can be sure that w is a completely different variable? I mean, whatever changes I do to w, will NOT affect otherObject, right?
View 2 Replies
ADVERTISEMENT
Nov 24, 2010
I have a list of properties and values that i'd like to use to dynamically build an Expression(Of Func(Of MyClass,MyClass))
I can run through the list and create each Expression by itself, but the only way I know how to combine them would be to use Expression.And or Expression.AndAlso, but that returns a BinaryExpression rather than my original Expression(Of Func(Of MyClass,MyClass)).
View 1 Replies
Dec 2, 2010
In C# .NET 3.5, is there a way to instantiate an object given its string name? For example, suppose I have a DLL (e.g., MyClass.DLL) which contains type MyClass. Is possible to write something like... Object myClass = SomeMethodToInstantiate("MyClass"); // ? Is it possible to do this in VB .NET 3.5?
View 2 Replies
Feb 6, 2011
why don't we declare a variable for instance variable with dim not private?
View 3 Replies
Aug 4, 2009
I have a for next loop looping through a dataset.I want to create an instantce of a class for each row.How can I create another instance/variable for each row?
View 5 Replies
Nov 12, 2010
i have
VariableA as Class1
Variable1 as string
Variable1 = "VariableA"
I want to be able to use Variable1 to get access to VariableA(?).
So i want to able to do something like
VariableA.Property1 = "test"
But like this:
Variable1.Property1 = "test"
View 5 Replies
Apr 7, 2010
How many instances of a shared variable will be created in a class? just one? correct
[code]...
So, in other words, the DocumentDelivery class will only have one instance of RenderList, correct? can somebody confirm?
View 3 Replies
Apr 10, 2011
Dim myObject As Something There I defined my variable myObject of type Something. But, as you can see, I am giving it no value yet. Sometime on runtime I want to check if myObject is holding a value or not. I tried this: If myObject <> Nothing Then But apparently I can't do such comparison.
View 3 Replies
Jan 28, 2010
I need a static variable to get a ListItemCollection from a List control (I can do this, but if I don't set it as Shared It's not preserving the values as it should). The thing is that this class is a SharePoint webpart, so I most probably will be using the webpart more than once, and I need this variable to be unique to each webpart, which shared doesn't accomplish.I tried everything you can imagine. I placed a Static variable within a Sub (shared and not shared), I tried it with Properties (also Shared and not shared)...
View 3 Replies
Jul 17, 2009
how do I refactor all my instance variable to have all the get and set method? I tried RefactorVB but it seems like it can only refactor 1 by 1.
View 2 Replies
May 10, 2010
Imports System.Data.SqlClient
Public Class form1
Private strconn As String = "Data Source=" + textdatabase.Text + ";Initial Catalog=" + databasetext.Text + ";Integrated Security=True"
[Code]....
whats wrong with that code i have 2 text fields reference so why obj ref not set?
View 3 Replies
Sep 29, 2011
I am trying to create new variables inside a class after creating its object at runtime. The problem is that I don't know the variable names or the value beforehand so I have to create the new variables at runtime.
[Code]...
This is a more elaborate explanation of my code. If you observe that in the Eval function I have tried to evaluate Fval(abc). Now the object array abc is not declared in the Test class because it existence is not known beforehand. What I want to do is create an object array abc of length 2 and populate it with some values and when Fval(abc) is called then then the value of index 1 should be the return value of Eval fucntion.
View 2 Replies
Jul 26, 2010
I've got some code that looks like this:
If ediFileGroupAbbr = "NIPDSINV" OrElse ediFileGroupAbbr = "WWPDSINV" Then
Dim p As New PrivateBillingAdapter_ForN(ediFileGroupAbbr, businessLocationID, mode, EDIJobItemLogID, BusinessUnitID)
Return p.ProcessEDI(True, False)
ElseIf ediFileGroupAbbr = "FOPDSINV" Then
[code]...
to which I'm passing in a value of ediFileGroupAbbr = "FOPDSINV". But the code is executing as if it's dropping into the third condition (p is a PrivateBillingAdapter). So I've stepped into the code and, sure enough, it drops into the second condition. BUT, if I step into the execution of the constructor, the debugger jumps to an odd place in the code - sort of the middle of a method and not on any actual line of code.A couple clicks and it hops back out of the constructor, still in the second block of code. But if I mouse over the variable p to see it's type, boom, its a PrivateBillingAdapter (from the third block).Like I said, something is clearly wrong but I don't know what. I've tried rebuilding several times but with no new results.This is VS2003, framework 1.1 with VB.NET.
View 1 Replies
Mar 3, 2011
Here's an example of what I'm talking about...
Public Class Sample1
Public Shared Function MyValue() As Integer
Return 0
End Function
Public Sub Code()
[Code]...
Me.MyValue gives a warning in VB.NET and (the equivalent code gives) an error in C#. Is there a particular reason for this? I find it more intuitive/natural to access the shared function using 'Me.MyValue' - but I avoid it to keep my warnings at 0. Did someone else just decide 'Nah, it makes more sense to do it the other way' or is there some technical reason I don't understand?
EDIT: I was thinking of it wrong, more like a 'sub class' in OOP. Even if something is declared in the base class, you access it through the instance you have. But that relationship is not the same with shared or static.
View 6 Replies
Mar 7, 2009
there is a way to turn the following code into a sub so I don't have the same boilerplate show form code in use a thousand times in a program:
Example:
Public InstanceOfFrmGeneric As frmGeneric
If InstanceOfFrmGeneric Is Nothing Then
InstanceOfFrmGeneric = New frmGeneric()
[code]....
View 4 Replies
Jun 2, 2010
I'm tyring to pass a variable data type to a template class. Something like this:
frmExample = New LookupForm(Of Models.MyClass) 'Works fine
Dim SelectedType As Type = InstanceOfMyClass.GetType() 'Works fine
frmExample = New LookupForm(Of SelectedType) 'Ba-bow!
frmExample = New LookupForm(Of InstanceOfMyClass.GetType()) 'Ba-bow!
[Code].....
I'm assuming it's something to do with the template being processed at compile time but even if I'm off the mark there, it wouldn't solve my problem anyway. I can't find any relevant information on using Reflection to instance template classes either.
(How) can I create an instance of a dynamically typed repository at runtime?
View 4 Replies
May 17, 2011
It's a simple concept, but one I've never been taught
View 1 Replies
Jul 26, 2011
The MyClass keyword behaves like an object variable referring to the current instance of a class as originally implemented. MyClass is similar to Me, but all method calls on it are treated as if the method were NotOverridable. I can see how that could kind of be useful, in some specific scenarios. What I can't think of is, how would you obtain the same behavior in C# - that is, to ensure that a call to a virtual method myMethod is actually invoked against myMethod in the current class, and not a derived myMethod (a.k.a in the IL, invoking call rather than callvirt)?
View 3 Replies
May 17, 2010
In what scenarios would one use the MyBase and MyClass keywords in VB.NET?
View 5 Replies
Nov 3, 2009
i have a code like this
'bug_message is a public shared property
Public Shared Sub bug(ByVal bug_message As String)
msgbox(XX_format(MyClass.bug_message, bug_message))
End Sub
however i get this error: MyClass is valid only within an instance method. I do not wish to use the actual name of my class, and if i could i would prefer to keep the name of the argument as bug_message as well.
View 18 Replies
May 7, 2010
I'm using VS 2010 so I have auto-implemented properties.I have a class and I want to access the properties by a string.[code]But, I also want to be able to access the variables something like this way.[code]How can I setup MyClass to work both ways?
View 7 Replies
Sep 14, 2011
Is there a simple way to remove Objects from a List by using a specified value?I add 2 persons to a List, how can now I remove a person by a name without using any Loops? (if possible)
[Code]...
View 3 Replies
Mar 13, 2009
I am trying to use myclass.cs from aspx.vb but receive error "myclass not declared" when I give command:
Imports myclass
View 3 Replies
Oct 6, 2009
I'm getting a: mypage.aspx.vb(390,0): error BC30002:Type 'MyNamespace.MyClass' is not defined when I try to compile, run, etc. my website. What's really odd is that I don't have anything in my Error List before or after I do this. I wouldn't have an idea of what was wrong, except I have my compile verbosity turned way up. The line it's failing on looks like:
[Code]...
View 1 Replies
Mar 16, 2010
Traditionally, class/type name is literally spelled inside its definition.
Public Class MyCustomClass
Public child As MyCustomClass
Public Shared Function Clone(ByVal original As MyCustomClass) As MyCustomClass
End Class
This is not a problem most of the time; C-languages even use class name as constructor methods' name. But consider a generic declaration:
Public Class MyListOfIntegers
Inherits MyCustomList(Of Integer)
End Class
[code]....
This scenario has 2 issues. The first one is that constructors are not inherited, and you have to provide pass-through wrappers in every derived class, — this is quiet dumb, but tolerable. The second issue is more severe: derived class inherits CloneMe() method which returns MyCustomList(Of Integer) , not MyListOfIntegers ! Every returned value must be manually DirectCast 'ed for further use with methods that expect MyListOfIntegers . This issue, together with the first one, renders inheritance of generic class almost useless.
So I need a "MyClass" alternative for static type-binding inside type definition. In case of generic type that is referencing other compound types, task could be accomplished by adding second parameter to type section:
Public Class MyCustomList(Of T, TList)
...
Public Function CloneMe() As TList
[code]....
But since we must reference our own type, it would create an infinite recursive loop of additional typeparamlist arguments. How can this be resolved, aside of creating separate classes without generics?
View 11 Replies
May 7, 2010
I can't seem to find the correct words to search for an answer. I'm using VS 2010 so I have auto-implemented properties.I have a class and I want to access the properties by a string.
Public Class MyClass
Property Prop1 As String
Property Prop2 As String[code].....
But, I also want to be able to access the variables something like this way....
Dim MyVar = New MyClass
MyVar.Items("Prop1") = "Prop1 Value"
MyVar.Items("Prop2") = "Prop2 Vaule"
How can I setup MyClass to work both ways?
View 1 Replies
Feb 22, 2011
dim oXT As New Generic.SortedDictionary(Of String, MyClass)
[Code]...
View 4 Replies
Jan 12, 2011
In the Session_Start of the Global.asax i have
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Session("login") = False
[code]....
Why i am getting error the error Object reference not set to an instance of an object. at line
If Current.Session("login") Is Nothing Then
while checking for the login state as follows?
If GetLogin = False Then
'Do something
End if
I mean i have already created the instance on the Session_Start... Haven't i?
View 1 Replies
Jun 7, 2012
I want to created a nested class that can only be visible to and instantiated from the parent class.But I also want to be able to use an instance of the nested class through a public variable of the parent class.I tried making the nested class private, or making the nested class' constructor private, but it won't compile.Is it possible to do this in .NET?
[Code]...
View 3 Replies
Apr 15, 2009
Hi, I'm just beginning to teach myself how to do OOP in VB 2008 Express. I have a quick question after seeing a video online.Is a VB variable the equivalent of an 'instance' in Flash and a VB object like a 'symbol' in Flash? Is this what it means by a variable being a reference or pointer to an object and not the object itself?
View 5 Replies