How Does Block Level Scope Work With Dim As New

Jan 21, 2010

While DataReader.Read
Dim Foo as New FooBar
Foo.Property = "Test"
Loop

In VB.net, does this create a new Foo instance every for every loop? Or just one Foo instance with block level scope? Do all blocks (If..EndIf, For..Next) work the same in this regard?

View 3 Replies


ADVERTISEMENT

VS 2005 Scope Of Using Block

Aug 17, 2010

[code]In the above code what will be state of 'conn' variable and the 'cmd' variable and the State of the Connection to the DB in the following two case

i. Me.Close line

2. If any error occurs

View 3 Replies

.net - Should Events Be Raised In New Threads To Not Block Current Work?

Dec 15, 2009

I'm currently designing an assembly that will be used by third parties. One of the classes has a long process of TCP connections and it informs about its process using events. For example

''# Do stuff that takes some time
RaiseEvent CompletedFirstPartEvent()
''# Do stuff that takes some time

[Code].....

What I've seen if that if the handler of one of those events takes too long (or even worse, it blocks) I can have timeouts and it's hard for the developer to see that one class is not working fine because his handler is taking too long.

I was going to fire the events in a new Thread to avoid this issue but this looks strange to me because I've never seen something like that, what I've seen until now is the developer spawning a new Thread if his handler was going to be timeconsuming. So the question is:

What would you do? Create a new thread or force the user to create his own thread? (Or is -there a better approach that I don't know?)

View 6 Replies

Complete My "home Work" Assignment For My A-Level Computing?

Feb 4, 2009

I'm not looking for anyone to complete my "home work" assignment for my A-Level computing as I've done this now and I think it's impressive. What I am now looking for is help in extending what I have done and making it better.

History:I have built my application in Visual Basic 2005 Express Edition. It is a Console Application. After filling in the questionnaire the user gets given results and all this information is stored in a .txt document (Notepad). I want the data that is put in to the application to send infomation to the user's e-mail address. I have been looking around the internet and it says it could do it but it needs Outlook express.

View 3 Replies

Application-level KeyUp/KeyDown Events (not Windows Form-level)?

Apr 1, 2012

I am creating an Excel add-in written in VB.NET. I would like to bind KeyDown and KeyUp events to the spreadsheet to record when the user presses and releases the arrow keys while navigating the spreadsheetIdeally, these events would be built into Excel alongside the native SheetActivate and SheetSelectionChange events, for example. Alas, they are not.

View 1 Replies

What's The Difference Between Dim On The Member Level And Static On The Procedure Level

Jan 6, 2010

In Visual Basic 2008, there's two different ways that I know of to accomplish the same thing:The Dim on the member level:

Dim counter1 as integer = 0
Dim counter2 as integer = 180
Public Sub SampleSub1()

[code].....

View 1 Replies

Top Level SQL Table Row - Save The Top Level Automatically?

Mar 18, 2011

I have created a simple program which uses a two tier structure of SQL Tables.At the top level, one record holds the date of the activities and linked to it using its primary key as a foreign key, three subordinate tables hold time stamped records.The issue I have been unable to solve is that before adding any of the lower level records for a given date, a newly added top level record must be saved to the database.Doing this manually is simple - but can I rely on my users to remember to do this before they start plugging in the lower level data?I thought not, so I am looking to save the top level automatically.I've failed miserably but I refuse to believe that it's not possible.

View 14 Replies

Multiple Level Of For Each And Linq In Each Level

Feb 12, 2011

I have multiple level of For Each and in each level, i have a Linq that is the 'In' criteria as in:

[Code]....

It will go inside each for (because the value is not nothing), however, it will only loop (next) in the very inner 'For Each t In tFor'. After it is finish inner loops, the outer Fors' or Next will not execute... even thought there are more than one values in that 'In'... like 'sFor' or 'fFor'. i've noticed while debuging, while break at the for (for example 'sFor', before stepping in), i get the error message:

"Enumeration yielded no results" when i expand the result for that variable and it will not step into it. but if i do not expand the result, it will step in. It seem that some how, once an element is accessed for that 'In' collection, it breaks (meaning does not loop for the rest of the elements) the next for that collection is this a bug or am i missing something in Linq? BTW: i believe it has something to do with the SqlDataReader in the Linq. I'm working with IAsyncResult.

View 5 Replies

Import A Platinum Level Advisor .jar To Use With This Platinum Level Product Key?

Nov 10, 2009

U0161 import a Platinum level Advisor .jar to use with this Platinum level product key.How I can get this and import it to continue my completion of setup of mysql download?From where I can download that file?To enable this application, please provide a MySQL Enterprise Product Key or your MySQL Enterprise credentials.

View 1 Replies

Javascript Scope With Asp.net?

Jul 2, 2009

I'm probably missing out on something fundamental here but it seems rather tricky and confusing to me so here goes.to demonstrate the issue I have the following example .aspx page

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

[Code]...

View 3 Replies

Asp.net - For Each Looping Getting Out Of Scope Exception MVC?

Jun 18, 2012

Am looping a list object. The list contain 18 object. The loop running 18 times but the end of the 18th one getting Object reference not set to an instance of an object..

@For Each Slogs As SFAMobile.MobileServices.CustomerDetail In Model.Customers
@<option value='@Slogs.CustomerId' @selectedVal >@Slogs.Name ( @Slogs.CustomerId ) </option>
Next

View 2 Replies

Keeping An Item In Scope?

Aug 31, 2010

I have been working on a VB app to edit an excel document. I want to keep my excel workbook in scope for the whole app.

For example here is how my program looks now

private sub
open workbook
end sub

private sub
reference workbook
end sub

I want a way to just call my workbook at the top and have all of my subs recognize it. I guess like a global variable or something.

[URL]

View 5 Replies

Scope - VB Equivalent Of {} Nesting

Feb 27, 2009

Does VB.NET have any scope nesting operators like {} in C type languages? Example C++ type code:

int i;
i = 0;
{
int i;
i++;
}

View 2 Replies

Variable Scope Error/

Dec 16, 2011

ok I have two procedures:This is for the tick of a timer

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
intTickCounter = intTickCounter + 1

[code].....

View 4 Replies

Variable Scope Outside A Class?

Jun 12, 2011

how to declare scope for variables outside their class?

Here's what i have in a class known Create_User:
Public Class Create_User
Public conn As New SqlConnection(My.Settings.HotelConnectionString)
Public usercmd As SqlCommand

[Code]....

How can i increase the scope of these variables to be used in another class? I dont want to keep declaring them again and again.

View 4 Replies

Event Variable Scope Across Whole Project

Jun 7, 2011

I'm moving from VB6 to VB.net and there are a few things confusing. In vb.net, your program just automatically has a form, now the form in in a class and so it may or may not be there. In vb6, the main subroutine controls program flow and I don't see that in vb.net. However, my biggest problem is that I have a com dll that has a connect class with events. I need to be able to access these variable outside of that class. I don't understand how to do that. I can't seem to declare public withevents outside of the class and in the namespace so it can be shared with other code. Its say "not valid" in Namespace.

So what is the best way to do that. Do I create a set/get property for the class that holds this value? And, if I do that, is the connect class automatically instantiated as a part of the COM dll? Right now I don't instantiate the connect class, I assume the application does. But I'm not sure exactly how the property of the class would be set...perhaps I would need to call the property set from the on-connection method. Anybody know what the answer to these two questions are and this 3rd one? How can I have a variable that has "events" have scope across the entire project?

View 3 Replies

Let Users Set Application Scope Settings?

Mar 19, 2012

I am writing an App that automates file uploads from users desktops to a specified file server. On the first run of the app, I need the user to select a file server and save it for all other users of that PC. I thought I could do this
with application settings but it appears it is not suitable for this purpose. I need suggestions on how I can make this work.

I thought about a registry setting but the user may not have permission to edit the registry based on group policy/security settings.

I also thought about creating an XML file with the file server name that I can read from the installed project directory, but I was hoping there was a more streamlined way.

View 14 Replies

Narrowing The Scope Of Sub In Inherited Class?

Apr 5, 2011

Below is example code of what I want to do:

Public Class Test
Sub New()
Dim cool As New B
cool.Doit()

[code]....

View 6 Replies

Php - C# Or .NET Equivalent To Scope Resolution Operator?

Nov 22, 2011

I am porting php code to vbnet (i'm a little better at vbnet than c#). In the php is the scope resolution operator.

Here's the bit:

$args = phpZenfolio::processArgs( func_get_args() );

Equivalent in c#/vbnet?The whole function is the following which i gues is equivalent to the sub new in vbnet.

public function __construct()
{
$args = phpZenfolio::processArgs( func_get_args() );
$this->APIVer = ( array_key_exists( 'APIVer', $args ) ) ? $args['APIVer'] : '1.4';

[code]....

View 2 Replies

Public Function With Form Scope?

May 17, 2012

I have a Function for checking the input in a textbox and only allowing Numeric & Backspace; everything works fine so far. My form is for financials and it has about 20 textboxes; they all receive Numeric only data; there is NO alpha data on the entire form required. Note in the snippet below that I don't even need a decimal point as well.

Is there a way to handle ALL textboxes on this form without having to place the Function call in each textbox KeyPress event. took a long (5 year) hiatus from developing VB6

Public Function TrapKey(ByVal KCode As String) As Boolean
If (KCode >= 48 And KCode <= 57) Or KCode = 8 Then
TrapKey = False

[Code].....

View 5 Replies

Public Variable Goe Out Of Scope In Private Sub?

Aug 23, 2009

I have a public variable which seems to be going out of scope. I am confused as it has been dimensioned as a public variable: Public xlCell as As Microsoft.Office.Interop.Excel.Range

I originally had all my code in the same module in the same project and it was wrapped within a For/Next Loop (Example 1). I decided to clean up my code and make it more modular (Example 2). All the code is still in the same module in the same project.

Upon doing so, my public variable is not recognized in any of the private subs that I have created. I keep getting the following error: Message="Object reference not set to an instance of an object." When I test the variable using ?IsNothing(xlCell) in the Main Sub I get False in the main sub. this tells me te variable is recognized. However as soon as the Call SelectCaseSub() is triggered, I get a True value for ?IsNothing(xlCell). Why is this? Shouldn't this variable be in scope regardless?

[Code]...

View 6 Replies

Safe To Use An App-scope Regex Object?

Nov 28, 2011

I have a complex Regex which is used to help strip out HTML from user input. I'm aware that .NET caches static Regex calls to some extent, but this one is big and used frequently, so I'd like it to hang around.[code]...

View 1 Replies

Scope Of .NET's List(Of T).Reverse Method

Apr 7, 2009

I've got a simple function that takes a List parameter. While working with it, it copies it and reverses the copy using .NET's List(Of T).Reverse method.

[Code]...

View 6 Replies

Scope: Access A Collection In Another Form?

Nov 10, 2009

I am trying to acccess a Collection in another form

vb
MsgBox(frmNetworkTest.servers.Count)

What I do this from the same form, I get 16, but when I run this code from a different form, I get 0.The variable is declared public.

vb
Public servers As New System.Collections.ArrayList()

View 5 Replies

Variable Scope And Event Timer

Mar 15, 2011

I'm trying to create a simple media player that will scan a directory for certain filetypes, add them to a playlist then play a random playlist entry - changing every x seconds.I figured this would be simple in VB and, to an extent it was. I have the code running that chooses the directory and plays the random file.I just need to now make this repeat every 30 seconds or so.I have all the coded attached under the sub for the 'open' function of the player so it's quite flat. I think I need to use a timer here, to trigger the routine to pick and play the media every 30 seconds?In doing this I think I need to break the variables out of the function I currently have as they need to be shared between the timer loop function and the central 'creating file list' function.

I'm having trouble - I'm no coder (as you'll tell!) and although getting this far was easy I'm now (I think) bumping into threading / variable scope issues which are a bit of a brick wall.I've tried making the variables public / global by declaring in the class rather than the sub but I get errors at runtime. Presumably because of how I'm creating the windows media objects? [code]

View 8 Replies

Variable Scope When Using Forms VB2008?

Mar 11, 2010

where I should declare my variable when using forms and the scope in my test code.

In my code below I have declared variable x in my form1 which can be printed in form2.

But when I create a structure in form1, initialize an array of the type protorec and try to assign values to cards(1).firstname etc... I get a "declartion expected" error.

Why does it work for x but not for cards(x) my array of records?

Public
Class Form1
Public Structure protorec

[Code]....

View 16 Replies

VB 6 - Duplicate Declaration In Current Scope?

Jul 7, 2009

I am attempting to dynamically dim a variable (i.e. create instance based on user selection).

For example, based on the users selection from a combo box containing report names ("Report A", "Report B", "Report C", etc.), I would like to Dim a report variable (MyReport).

[Code]....

View 3 Replies

VS 2005 Error Handling Scope?

Mar 10, 2011

plain how error handling scope works. What I mean by that is if I have a sub called ImportData and in there I have a for loop to go through a list of files and in the for loop I call another sub routine called CheckData. All have catch error in. If a sub has a catch error in where does it go from its call.

Private Sub ImportData
Dim iLoop as Int16
Try

[code].....

View 10 Replies

.net - Public Enum With One Item In A Different Scope (Like Friend)

Nov 18, 2011

Is there a way to do something like this?

Public Enum CarMakes
Honda
BMW
Mazda
Friend Yugo
End Enum

I need to expose the the Enum to Public except for one of the items I just want to be available from inside the assembly.

View 1 Replies

C# - When Variables Defined In The Inner Scope May Be Garbage Collected?

Sep 28, 2009

If I want to narrow scope of a variable in C#, I can introduce additional braces - i.e.:

class Program
{
static void Main(string[] args)[code].....

In the ide, I can no longer reference y outside of the scope introduced by the new braces. I would have thought that this would mean that the variable y would be available for garbage collection.(it is interesting to note that when viewing the compiled code using reflector it appears that there is no difference with or without the additional braces)Is there any way similar to this to narrow scope when using VB.net? Does this have any impact on when variables defined in the inner scope may be garbage collected?

View 4 Replies







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