VB 2008 Why Are Static Variables Set Equal To 0 In The Declaration When 0 Would Be The Default Value Of The Numeric Variable

Apr 21, 2010

Why are static variables set equal to 0 in the declaration when 0 would be the default value of the numeric variable anyway when it's first declared? Not including the "=0" in the static declaration seems to work with no problem.

View 2 Replies


ADVERTISEMENT

Local Variables In Shared Method Work Like Static Variable In C?

Aug 23, 2011

Will the list in this shared method keep its state throughout the life of the method? Or will a new list be created every time this method is called?

[Code]...

View 3 Replies

VS 2008 Declaration Of Variables Vs Properties?

Jan 22, 2011

I have several classes that use a bunch of strings for directories, arguments, etc.

At the moment, they're all just declared globally within the class like so:

VB.NET
Private str1 As String = "path"
Private str2 As String = "path2"
Private str3 As String = "arg"

To me, that looks awful and doesn't seem like the proper way of doing things. So, I was thinking, should I make a property for each string and then use a constructor to initialize them?

Would that make a difference at all? Is that the proper way of doing things?Also, some strings are used in a ton of different places and they're basically just being copied from one class and pasted into another. So, do you think I should do what I suggested above, but with a class whose sole purpose is to house those strings so that the code isn't duplicated a million times everywhere? Would that be the most efficient way of doing things?

[Code]...

View 8 Replies

Use Variables Or Properties, And Global Or Static Variables In A Class?

Jun 9, 2012

I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:

Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer

[code].....

View 3 Replies

VS 2008 What Type Of Variable Is Equal To A C++ Char

Jan 13, 2010

i am using a c++ dll to control a usb device. a while back i created a vb6 program that interfaced with the dll.it worked perfectly.now i am trying to make one in vs2008.here is the header of the function i am trying to use in teh c++ dll [code]but this get no value for textbuffer.and after the function is called a few times it gives me a memory error. i think it is because the string is not fixed length.is there a way i can get this to work in vb.net without rewriting the dll

View 3 Replies

VS 2008 Static Variable's Fault?

Jun 14, 2010

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:

[Code]...

View 12 Replies

VS 2010 Set 2 Variables To Be Equal

Jan 29, 2011

I would like to set stringa and stringb to be equal and then clear stringa like so:

Dim stringa as String = "abc"
Dim stringb as String
stringb = stringa

[Code]....

However this code sets up a link between the 2 variables, so when I clear stringa stringb is also cleared.

View 1 Replies

Declaration Of Variables In2010

Jun 7, 2012

I am creating a kind of a "naive" search engine.What I have done is distributed words in files where each file corresponds to the starting letter of the words (i.e. if its English, then 26 files are there)Then when the search system loads I am loading all the words in hash tables (26 hash tables corresponding to 26 alpha-characters) for which I am using an array of structures.The problem is after declaring the variables in a Form load subroutine, the variables are not able to use those values in other subroutines..How do I properly declare them so their values persist?

View 1 Replies

Default Value At Declaration Or In Constructor?

Mar 4, 2011

One would think I'd already know this, but I never really gave it much thought before now. When declaring a member variable for a class, is it better to set the default value at the declaration

Private m_strMyVariable As String = ""
Or is it better to do it in the constructor
Private m_strMyVariable As String

[Code]....

Should I maybe always specify a value at declaration, even if it's Nothing, and just override that value in the constructor(s) as needed? Or is it situation specific? If so, a really quick rundown of which situations might warrant which treatment would be nice.

View 4 Replies

Static Variables On A Web Garden?

Aug 17, 2010

Do vb.net static variables work on an IIS web garden?

View 1 Replies

Difference Between Static And Shared Variables In .NET?

Jun 22, 2009

exact diff b/t Static v/s Shared variables in VB.NET?

View 3 Replies

XML To Variables - Setting Label To Equal Text Inside Tags

Jul 29, 2009

I have an xml document on the internet right. Lets say it contains:
<tag>goose</tag>
What I want to do, is when the user clicks a button in my vb form it looks for the "tag" tag and finds the text inside the tags which is goose. Then it sets a label to equal goose, or whats in those tags.

View 7 Replies

.net - When Are Inline Static Variables Initialized In A Class

Aug 10, 2010

Suppose we have a class like:

Public Class Question
Private Shared _field as Integer = CrazyIntegersRepository.GetOne()
' Some other useful things go here
End Class

And the method GetOne throws an exception... How can we manage that? Is a good practice to rewrite that into a static constructor? When is the GetOne method going to be executed if we leave it there in the inline _field declaration?

View 3 Replies

Sub Main In A Project-static And Global Variables

May 17, 2009

I try to create a sub main in a project but i can not.I have create a module called Module 1 and inside i have created a Main Sub which is intended to creta a thesaurus_form class instance , like this Code: Module module 1Public Sub Main()Dim thesaurus_form2= New Thesaurus_formEnd SubEnd module.Instead of this, once it has cretaed a first instance of the thesaurus_form class, it creates another one what i dont want at all..How can i do do make it execute the code which is inside the thesaurus_form_load sub..I also can not create a global variable or a staitc variable, because i receive this message.static is not valid in a member variable declaration.

View 2 Replies

Use Of Static Local Variables In Lazy Loading Property

Sep 19, 2011

I just recently learned about the uses of static local variables in VB.NET and wondered about it's potential use in lazy loading properties.

Consider the following example code.

Public Class Foo
Implements IFoo
End Class

[Code].....

As far as i can see, this has a few advantages over the usual implementation, primary your inability to access the variable outside of the property, as well as not having to use an additional variable.

My question to you is: Which of those is the "right" way to do it? I know that static variables have additional overhead, but is it bad enough to create, in my personal opinion, unclearer code that can be misused easier? How much performance do you lose compared to the "traditional" method? How does it matter for small classes compared to huge factories?

View 2 Replies

Variable Name Declaration With []

Mar 8, 2010

In this

Dim [end] As Point = e.Location

what is the significance of the [] 's?

View 4 Replies

Why Is 'rm' (a Variable For ResourceManager) Equal To Nothing

Apr 13, 2010

How do I declare/define a ResourceManager in the following code so it doesn't equal Nothing when it reaches rm.GetString("Magnitude") in the following code? My.Settings.. is returning a valid string.

Imports Gigasoft.ProEssentials.Enums
Imports System.Resources
Imports System.Configuration

[code]....

View 6 Replies

Getting Sql Variable Declaration Error

Jan 19, 2011

I have the following form[code]...

and when I run my app, I get a SQL error that tells me that I need to declare a value for '@payperiodstartdate' but I know that that value is declared because the first query runs fine. I am told that the line where the error is is line 59, which is this line [code]...

View 1 Replies

Variable Declaration Convert From C#

May 17, 2010

I'm working on a home project using DirectShow.Net. to learn some VB.net. Most of the examples I've found have all been in C# so I'm looking through code for ideas and converting where I need to. I keep stumbling upon these declarations and I'm unsure how to convert it to a VB.Net statement.[code]Then the second part seems to be assigning the value but as its made up of two parts im unsure how that works?

View 2 Replies

Check If A Variable Is Equal To Some Values Or Not

May 15, 2011

I want to check If a variable is equal to some values or not, for example:

if a = 1 or a = 5 or a = 7 or a = 10

is it possible to do it like sql:

if a in (1,5,7,10)

View 3 Replies

Function To Evaluate Two Numeric Variables At T And T-1?

Sep 25, 2009

I need the create a function with two variables Price1 and Price2 and the following rule:

if Price1 > Price2 at time t and not (Price1>Price2) at time t-1 Then
result=true
else
result=false

I should be able to use a loop to store the time t and t-1 Price1 and Price2 values.How can I do this in VB.net

View 11 Replies

Static Variable In Asp.net?

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

LINQ Variable Declaration Type?

Feb 1, 2010

[code].....

View 4 Replies

Loop Variable Declaration Efficiency?

Jan 27, 2012

wondering about the relatively efficiency of declaring oop variables in the loops, emselves, or declaring them before first use. Here are some examples:Declare early:

Dim ix As Integer
Dim currentNode As System.Xml.XmlNode
For ix = 1 To 100

[code].....

View 9 Replies

Variable Declaration (Dim) And Assignment In 1 Statement?

Oct 24, 2011

I have noticed in VB.Net that most Dim statements also include an assignment. Eg:Dim myvar As String = "Hello World"As this wasn't possible in VB6 I have always done the following:

Dim myvar As String
myvar = "Hello World"

View 3 Replies

Variable Declaration Inside A Loop?

Aug 26, 2011

For i As Integer = 1 To 10
Dim j As Integer = 10
Next

now my question is, Is memory allocated to j every time its executed inside for loop? or only value of 10 is assigned on subsequent iterations?

View 2 Replies

Assign A Number To A Single Variable It Does Not Equal The Same Value?

Nov 2, 2010

I have been searching the internet trying to understand in its simplist form why this behavior happens.

Dim mysingle As Single = 456.11 Dim mybool As Boolean = mysingle = 456.11

In the lines above mybool becomes false. I found this behavior when putting the single into a double I found extra digits showing. The .net documentations states a single is an approimate value I gatehr a single is a 32bit floating point number? But why are extra digits appearing when I have explicitly said what the number is.. surely the memory should store that numbers either side of my number are 0 to fill up the memory location?

View 3 Replies

Assigning Variable If Value Is Equal To This / That (Select Case)

Mar 19, 2012

I have 10 checkboxes on my screen. I have a variable setup called "case" as a string. I want to know how I can say:
If checkbox1 is checked then case would be equal to "this".
If checkbox2 is checked then case would = "that"
Example of something I tried to cook up but didn't work because it tells me that I can't only use this in a "select case".

Dim Case as string
If checkbox1.checked = true
case = test1
end if
If checkbox2.checked = true
[Code] ......

View 5 Replies

C# - Shared / Static Variable Should Be Nothing?

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

C# - Inline Definition And Long-declaration Of A Variable

Feb 20, 2012

im sure im mis-wording the concept but here it is anyways. I know in CSharp you can do

el.AppendChild(new UISize(file, "TSize") { CX = 95, CY = 20 });

which declares a temporary bucket variable and then assigns the associate property values to the variable. Which then sends it to the XMLElement AppendChild method. What is this design concept called? What is the conversion to VB.Net? I have tried using my own online utility that does a 90-95% conversion rate from C# <-> VB.Net. It has failed in this instance, and so need a hand-up on what i am looking to do to convert this from C# to VB.Net. I would really like to not have to do a long-declaration of a variable with assignments, if at all possible.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved