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)...
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.
If you run this code you will see that the 500 PictureBoxes that are added ( this is easier to show than adding pixels as a pixel is only a single point ) fall mainly on the diagonal.With regard the RANDOM class, why should this be like this when the bounds of the instances are? >>
p.Location = New Point(x.Next(0, Me.Width + 1 ), y.Next(0, Me.Height + 1 )) as in this code.>>
Under Visual Basic 2010, I am trying to define a specific instance of a static method that was created as a Java class. I have a vendor supplied dll added in as a reference.[code]...
But, I can't seem to define a specific instance of this method. Using "IntegrationMethod.getIntegrationMode()"always returns a value of zero.
There doesn't appear to be any way to "setIntegrationMode" to a specific value.
The documentatoin for this Class as provided by the vendor are shown below.
When I asked the vendor for assistance, their response was: "
Our javadocs for the IntegrationMethod class show that we provide three predefined instances of the IntegrationMethod class[code]...
I have procedure (Import) that calls a for a new instance of frmImportData. I also have a class name clsBatch that has a data table property called prpParametersTable.For some reason, I get an error (indicated below with ERROR>>>) when trying to assign prpParameterTable to cv_dtImport2. The error states "Object reference not set to an instance of an object.". Why does this error not happen when I assign dtBP to cv_dtImport1? Both cv_dtImport1 and cv_dtImport2 are equal to Nothing and in my Import procedure dtBP = prpParametersTable.
Public Sub Import(ByVal clsB As clsBatch) Try Me.cv_clsB = clsB
how to word this, as it is it's complex to understand the concept of the idea. Basically, I'm trying to use an interpreter pattern, based off of the code I used in php. In php the code is:
abstract class Expression { private static $keycount=0; private $key; [code]......
The problem I'm having is that the static variable is blank for each child using it. How can I have it where one child increases the keycount,and ALL of the children have the new keycount variable?
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?
Im creating a registration application where i have a listbox that displays a Course Name column and a Credit Hours column. I also have a textbox that keeps a running total of the credit hours of each course added to the list. When i remove a specific item from the list, i also want to subtract the number of the selected item from the running total in the text box. Essentially i just want to subtract a certain part of a list item from a variable i have.
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.
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.
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.
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?
I'm trying to obtain the values using the prospective GetValue(s) methods but I don't understand the syntax of the documentation. I'm sending the correct bindings (I believe) to filter the fields, and properties that i'm interested in usually
I am writing a code for a webapplication in vb.net. I am using a shared variable in the vb code.
Consider the static variable value is 3 for a user who hits the web application. Again when another user hits the same web application, whether the static variable will be 3 again or whether he will have a separate value for static variable for his session?
I have the following code: Public Class TestClass Public Sub Main() If theGlobal IsNot Nothing Then Throw New Exception("What gives!") End Sub Private Shared theGlobal As Object = Nothing [Code] ..... Why is theGlobal object NOT Nothing?
We all know what a Static variable means! Recently I came across a problem that I have no idea about! I even don't know whether I'm wrong somewhere or that is a VS fault. Whatever it is, I can't figure out the cause. Anyway, I simply opened a VB 2008 project and added 2 Windows forms to it: Form1 and Form2. Then I set Form1 as a MdiContainer by setting its IsMdiContainer property to True. Then I added a CommandButton to Form1 and put this following code into that:
what is the Equivalent of a Static class in VB.Net. Is it Modules?And When i used one of the C# to VB.Net conversion tools then the code "Public Static class Class1 " was converted to "Public NotInheritable Class Class1"
I've got a shared class (static in C#) which mostly carries some settings data that any class in the application can read and sometimes write. Also there are some static properties which holds some internal states.
Now I want to revert this class to initial stage of it. With all default variables etc. Assume that the user want to reset the current state and start over without restarting the application.
In a singleton model I'd simply renew it with something like this :
Public Sub Reset() _Instance = New MyClass() End Sub
However this is not possible in a Shared class. Or should I switch back to Singleton?
I have a C# dll and want to use it in VB.NET. I'm using C# 2008 Express and VB 2008 Express. I have added a reference in a VB project to the C# dll. When I create an instane of a class in the C# dll, it gives the following error messsage: "Type 'RF.RabinFingerprint' has no constructors". My C# dll code:
using System; using System.Collections.Generic; using System.Linq; using System.Text;[code].......
If I have a module in a VB.Net class library, will it's visibility be limited to the assembly? What I'm looking for is the VB.Net equivalent of a C# internal static class.
This questions is for VBers, it's irrelevant in C#.
In VB, when you create a module, all it's fucntions and members are available in the scope without need to type the module name, just like all the VB functions (Rnd, Mid, IIf etc.).
I want to create a module but I should have to explicitly write it's name to access it's members, i.e. it shouldn't be loaded to the scope like a namespace.
Update
For example, I have a Module of extension methods, I don't want all it's members to show up on the scope and in the intellisense.
I want it to be available only by instance.ExtensionMethod().