Support True Static Classes?
Sep 16, 2010
This is a problem. Because in VB terms its a class that CAN benstantiated(although only internally) and you can create member functions in the class. This is not possible in CSharp. Here you create a static class and if you create a member function the compiler will output an error.And who knows... somewhere down the line another developer picks up my class and starts creating shared functions that return instances of that class. I know this might be a design/documentation problem but it can still happen.
View 9 Replies
ADVERTISEMENT
Apr 23, 2011
when they say static classes should not have state/side effects does that mean:
static void F(Human h)
{
h.Name = "asd";
[code].....
View 3 Replies
Mar 27, 2010
[code]Now how do i do this in c#. I know there is not handles clause in c# so i need some function that is called and assign the event handlers there. However since its a shared class there is no constructor i must put it somewhere outside of a function.
View 2 Replies
Mar 4, 2010
I have a base class with several derived classes. I want all of my derived classes to have the same Public Shared (static) method with their own implementation. How do I do this? Is it even possible?
View 3 Replies
May 15, 2011
If I have a 'Shared' object defined in the App_Code folder; is that object shared amongst all users/visitors of my website? Or is it shared on a per-user basis?I don't know if that makes sense or not; but I've got a puzzle/solver I'd written earlier that I'm trying to incorporate into a simple ASP.Net site. It's probably poorly written, but I'd used a Shared boolean to determine if a solution had been found. The code works, now as an ASP.NET site, but if two visitors to my site were both validating their puzzle at the same time, would they both be accessing the same boolean?
View 3 Replies
Apr 28, 2011
I compiled some VB6 code on my Win7 x64 machine and the result .exe will not run correctly on any other machine. VB6 code is just a new template .exe file with one button, a reference to "Microsoft ActiveX Data Objects 2.6 Library" and the following code in the button press event: Dim db Set db = New ADODB.Connection It runs correctly on my machine, but no others (even other Win7 x64 machines) (Update: I found TWO other users where it runs and one of them is Jeff Atwood!, but most machines have the same problem)
[Code]...
View 2 Replies
Jan 23, 2012
I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.
View 2 Replies
Jun 13, 2012
How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:
Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()
[code].....
So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:
interface.Economic.MyMethod
interface.Currency.MyMethod
etc
This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.
View 23 Replies
Oct 24, 2009
Here is some example code of what I mean:
vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click
[Code]....
View 5 Replies
Jul 10, 2009
I m trying to raise Click event of Textbox explictly but I m getting "Derived classes cannot raise base classes" error.[code]....
View 1 Replies
Oct 2, 2010
i am using VS 2008 and just started to work with XAML and WPF. while opening in page(.xaml) in design mode i'm getting the error like this "Only TrueType fonts are supported and this is not a TrueType font".
View 7 Replies
Feb 11, 2012
I know that
Public Incognito As Boolean
is a variable called "Incognito" that is class-wide that is a boolean.My question is that is there a form-wide variable form that can like communicate with different forms. So if a variable in form1 is "True" than, how can you make a variable in form2 turns to "True" too?
View 1 Replies
Sep 24, 2010
so far i got
code
For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields
rtfAppend(item.Name & ":" & Tab & item.GetValue(Me))
Next
For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()
[code]...
which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?
View 1 Replies
Oct 13, 2011
Searching the internet finds no less than 700 different ways and opinions to accomplish what I'm trying to do, and I would just like to know the simplest, most bullet-proof way possible.
[Code]...
I simply want to extract the string "bar," which is inside <hostName></hostName>I can do this easily enough with simple string functions, but I'd like to do it with one of the .NET XML classes/methods.
View 2 Replies
Feb 9, 2010
I am rewriting a C# class in VB. The C# class has a static constructor in it:
static Class()
{
...
}
which, through the Call Stack, I found is called by the main window's InitializeComponent() method.Everywhere I've looked has told me that the corresponding static constructor in VB is just:Shared Sub New()
but this method is never invoked. Am I creating my VB static constructor right? Is it likely something else that has nothing to do with my static constructor?
View 1 Replies
Dec 15, 2011
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?
View 1 Replies
Nov 7, 2011
This will probably be a basic questions for the LINQ & architecture experts however I am failing to understand a problem i've encounted when trying to update a 'Static ObservableCollection.
Me.Grid1.ItemsSource = ContactList Me.Grid2.ItemsSource = From s In ContactList Where s.ContactTypes.Any(Function(t) t.ContactTypeName = "Christmas List")
If I add a new Contact with the ContactType "Christmas List" to the ContactList ObservableCollection, Grid1 reflects the additional Contact however Grid2 does not reflect the change unless I rebind.
Anyway to Reflect the change in Grid2 to show the new Contact with the queried ContactType
View 2 Replies
Dec 11, 2009
We have a DateTime Service that pulls the Database date down when we need to use a Date. Now, If I want to run a test using "Todays" Date using FitNesse, What would be the easiest way of creating a way to have (OurService).CurrentDate be static? We have a control that ads Days,Years, or Months to the current date.. and I would like to be able to test this.
View 1 Replies
Jul 15, 2011
I am currently using Visual Basics 2010 (Ultimate), and I am trying to modify a free-project listed here:I want the above project to use these hard-coded values below:Key= "087CF262E0E856B8F911B369EE027CF9330F6288343651B1198379A9813BC8C4"
IV = "11D2A07242B79C752E6B53CDD14792C9"So basically i want to encrypt AND decrypt with the above keys.
View 8 Replies
Jan 6, 2011
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?
View 2 Replies
Apr 28, 2011
how to limit static integre.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static a As Integer[code]......
View 2 Replies
Nov 3, 2011
In the following example GetList returns an instance of a static (shared) variable. That one needs locking in order to be thread-safe.But what about DoSomething which doesn't use any static variables outside the method? Does it need locking too?I'd like to clarify that in this particular case I expect DoSomething to always print 0-100 in sequence (i.e. no 0123745...) regardless of number of calling threads. Or, in general, that different threads don't affect each other's variables (printing to console is only an example). The language in the following example is VB.NET.[code]
View 3 Replies
Oct 2, 2011
Im trying to load a google static map in a winform. I found a control online that would helpme but i cant get it working. i got the control from Here. i was not able to drag on the control on to the form like others. i have also email the dev of the control but have not heard back yet.
[Code]...
View 1 Replies
Aug 17, 2010
Do vb.net static variables work on an IIS web garden?
View 1 Replies
Oct 11, 2010
I have an excel sheet developed by a vendor that I'm stuck with the current functionality as a short term solution. The users workflow have them pull 4 separate sets of data which they are copying and pasting into a different spreadsheet where they append the data to previous days' pricing for trend analysis. That macro is built looking for the first blank row in column A, simple enough.
However, they then add the current day's date to this other spreadsheet as an additional column to do that trending. I found a nice link to a site that mentioned I could do this logic by adding code by right clicking the sheet name and selecting 'View Code'. I then entered the following logic that states if column A is populated, populate Column T with today's date statically (Today and Now don't work because I need it to stay at that date when it is refreshed). My issue is that this works great if I enter test data into cell A and hit enter. However it is not populating the date if a copy and paste is executed into the column A. Is there something I'm missing or a recommendation to have this work with copy/paste?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2:A15000")) Is Nothing Then
[code].....
View 2 Replies
Nov 30, 2007
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"
View 1 Replies
Sep 14, 2011
I have a C# method in my datatier that I am trying to convert to VB.Net. I converted it to VB.Net but when I bring up the datatier class the method is not showing. It has been a long time since i have used VB.Net and forgot alot of things [code]I believe it has to do with the declaration, which i have as:Public Static Function UserActInfo(ByVal _eno As String) As useraccount..
View 1 Replies
Jul 27, 2010
I have three classes Employee, Manager and Salesman. Manager and Salesman classes inherits Employee class.
Employee :
Public MustInherit Class Employee
' Field data.
Protected empName As String
Protected empID As Integer
Protected currPay As Single
[CODE]...
Manager :
Public Class Manager
Inherits Employee
[CODE]...
Salesman :
Public Class Salesman
Inherits Employee
[CODE]...
Now I have created a object of salesman and manager using the following code:
Dim objSalesMan as Employee=new Salesman("xyz",1,2000,5000)
Dim objManager as Employee=new Manager("abx",2,5000,"production")
Is this a good programming pratice or should I use:
Dim objSalesMan as new Salesman("xyz",1,2000,5000)
Dim objManager as new Manager("abx",2,5000,"production")
View 6 Replies
Mar 27, 2009
Is this code correct or is there any possibility of some random threading deadlocks etc?
Is it a good idea to use static properties and locking together? Or is static property thread-safe anyway?
Private Shared _CompiledRegExes As List(Of Regex)
Private Shared Regexes() As String = {"test1.Regex", "test2.Regex"}
Private Shared RegExSetupLock As New Object
[Code]....
If it's not obvious code is compiling regexes and storing in a List(Of Regex) so they can run faster. And it's shared so every instance of class can get benefit out of it.
View 6 Replies
Nov 17, 2011
I have a field which is static and readonly. The requirement is that the value should be allocated to the field at the login time and after that it should be readonly. How can i achieve this ?
public static class Constant
{
public static readonly string name;
}
View 5 Replies