VS 2008 Class-Level Declarations?
May 29, 2009
I have a project that is structured as follows:
[Code]...
I want the module to execute first before anything else, and so I call module.main() from the MyApplication startup event. At about the point that program execution gets to the beginning of module-level declarations in the module, it also starts running though the class-level declarations in the thread classes, but long before the threads are declared or the threads are started in the module code. I can't figure out why it happens! Is there some way of supressing that until later (i.e when those classes are actually instantiated)?
View 2 Replies
ADVERTISEMENT
Mar 24, 2009
On my main application i have a button which shows an "advanced options" form, if the "debug" is checked i was trying to enable/disable visability of a couple of text boxes on the applications main screen but when i tried:
[Code]...
View 2 Replies
Sep 29, 2011
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
[code]....
View 5 Replies
May 6, 2010
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.>>
[code].....-2138214fdeb4
View 9 Replies
Dec 25, 2009
I'm trying to learn more about assembly security (something I have basically neglected until recently because security in general is such a huge topic), and I have a question about CAS assembly level declarations.I get how to use them (basically) and the more blunt points of the subect, but I'm still not clear on where assembly level declarations should be made. Basically, where in the solution do you put:
<Assembly: CodeCodeCode> _
View 4 Replies
Apr 9, 2010
Although I have been programming for many years, successfully, in many different languages, translating my large Word VBA application into VB 2008 Express is driving me crazy. While I understand the theory of OOP and have even been on object-oriented courses, it seems I can't declare my objects correctly and use them in my code. As far as I know, I'm not trying to do more than the "language" is capable of doing, but here goes.
I want to start with "aList" which would be a Collections.Generic.Dictionary(Of String, String) object. Then I want a "bList" which is also a a Collections.Generic.Dictionary object. I would like each bList item to have a few individual simple properties (like a Byte and a String) then an aList instance as well. The application then gets a bList key value from the user, "copies" the corresponding bList item values into a work area, and does the necessary processing using the various bList(aList) / aList(bList) item values from the work area. I say "copies" because I assume that part is simply going to be a pointer copy rather than a long copy of lots of strings. Note that I really don't want to start using arrays here, as the application makes alot of use of Word VBA Dictionaries and I'd like to keep it that way if I can. Incidentally, so far, I have all my global data declarations in a separate Class, not on any of the application's forms.
View 7 Replies
Feb 4, 2012
I have an issue with variables that are used to name For-Next loops. I have had this problem in a couple programs but not consistently, i.e. some variables work, some throw a warning (not an error).
The situation is this. I declare the variable along with all my declarations in a module-
Module MainModule
Public Counter1 As Integer
end Module 'MainModule
[Code]....
The type for variable 'Counter1' will not be inferred because it is bound to a field in an enclosing scope. Either change the name of 'Counter1', or use the fully qualified name (for example, 'Me.Counter1' or 'MyBase.Counter1'). In the past I've always broken down and changed the names to get rid of all those ugly warnings. Sometimes I have eliminated them from being declared in the module and declared them at call time. This is not how I program and I like to keep consistency throughout.
how I can get rid of this spotty, on-and-off nonsense? There is obviously a lot I don't understand about VS and I would have never taken it up but would have stopped 3 languages ago if I weren't forced into bulkier and bulkier languages (sorry about the rant. I feel OK now).
View 4 Replies
Nov 16, 2009
Dim wBrowser As New WebBrowserTabControl1.SelectedTab.Controls.Add(wBrowser)I used the above code to add a WebBrowser to a tab, but I have no idea how to use declarations for it after adding it in code. I'm mainly after the
View 4 Replies
Jan 11, 2010
I have a backgroundworker that needs to contact a webservice. But when I run the background worker it just hangs forever at the line where I call a method of the webservice. I suspect this is because the webservice is defined at class level.
View 17 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
Mar 20, 2009
I have a class which has various methods that I need to make public to only 1 other class. Is this possible? I don't want to make them public for everybody, just that 1 class.
View 1 Replies
Mar 5, 2012
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.
View 1 Replies
Mar 1, 2012
I'm working with .NET 3.5 and Nunit 2.5.10. I'm attempting to write some tests to validate our role-based security enforcement through the PrincipalPermissionAttribute at a class-level. The test appears to succeed (it gets a green checkmark) and the Assert.Throws call properly catches the exception, and all my other assertions about the exception pass. However, once TearDown is complete after a test has run, the exception is re-thrown by NUnit. So even though the test "passed", every one of the tests shows that an exception was unhandled exception was thrown 'while executing' the test run.
I'm guessing I'm doing something wrong, but can't figure it out. My test is:
Public Sub New_TheForm_NoRoles_DeniesAccess()
' attempt to create a new instance of the form, but it should throw an exception with an inner SecurityException
Dim ex As TypeInitializationException = Assert.Throws(Of
[Code]....
Basically, Initialize is normally called in the application with Nothing so that we use the Windows Principal. During unit testing, we instead initialize it with a GenericPrincipal that has no roles, so that we can test that a SecurityException is thrown.
The tests are passing, but NUnit just seems to be re-throwing the exception post-Teardown.
View 2 Replies
Feb 15, 2010
I had a strange problem editing a class in the property grid whereby the property grid would refresh incorrectly.I managed to reduce the problem down to a class with just two properties. I've included the code at the end to ease explanation.It basically boils down to a class with two properties. The first of which is expandable (a font)The class itself is expandable and also implements the CreateInstance method in the type converter.To see the problem, expand the font, edit, say 'Bold', and tab away. Two problems happen:
(1) The second property jumps up and ends up in the expanded font property.
(2) The '-' sign of the expanded font changes to a '+'.
The problem goes away by attaching ResfreshProperties(RefreshProperties.All) to the class. That's great, but I'd like to understand how it fixed the problem. I've had a look in reflector and can't find any examples of RefreshProperties being attached at the class level.
[code]...
View 1 Replies
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
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
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
Feb 3, 2011
I am converting an old Vb6 solution to .net 2.0 in vs2010. I've been working in C# for about 3 years now and .net for 5. I don't recall having this problem in C#, but if I want initialize a readonly collection of DerivedControlFoo Is there a clean way to do it besides creating a sub to do it all off somewhere else? I'd love to be able to do it at the class level at the declaration for readability and simplicity.
View 1 Replies
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
Jun 1, 2010
I used to do this is VB6:
Type Record
A As Long
B As String
End Type
Dim Rec As Record
When I keyed in "Type" in my declarations, I was asked to change it to "Structure". After that, I was not able to define anything inside. So, what do I need to do?
View 36 Replies
Apr 3, 2009
I am at loss with the code shown below. I wish to write the equivalent in ASP.NET 1.1 but have failed.
[code].....
View 6 Replies
May 23, 2010
Dim MyOrders As Order()
Dim MyOrders2() As Order
View 6 Replies
Oct 22, 2011
Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
[Code]...
This correctly returns the memory value as string. So yeah, now it's just the Single that's causing issues.
View 2 Replies
Dec 15, 2009
It is my understanding that all modules are initialized and that all their variables are set up prior to MyApplication_Startup. I have code that has worked well for quite some time (XP and Vista).The Myapplication_Startup code references variables and code located in a Module.However, with Windows 7 this does not work.Anny reference to a module (Data, SUB or FUNCTION) throws a Type Initialization error at runtime. How can I correct this behavior in Windows 7?
View 2 Replies
Nov 7, 2011
I'm new to programming. I'm using Visual Studio 2010. I'm taking into two introduction classes, VB and C# with .Net. I have seen the enemy and he is me. I hope that someone can please help me with my two errors.
I do not know how I created My.CopyOfMySettingsProperty but I do know they were created when I was trying to create a project by combining my previous four projects.Listed are the two errors from my error list window that I need to correct along with my offending code:
Error 1 'Settings' is ambiguous between declarations in Modules 'Assign5Multi.My.MySettingsProperty' and 'Assign5Multi.My.CopyOfMySettingsProperty'. F:ProjectsVBAVBAssignment4MoviesMy ProjectSettings.Designer.vb 34 13 prjAssign5Multi
[Code]...
View 2 Replies
Jul 3, 2009
I Changed the following: Dim UserFile As New System.IO.StreamReader(sPath & "" & UsernameBox.Text & ".txt")Dim aString As String = UserFile.ReadToEnd() (The code above says that 'UserFile' and 'aString' are Unused variables)
[Code]...
View 3 Replies
Aug 31, 2010
I need comprehensive tutorials of VB 2008 for beginner's which give additional support to my studies so that I can learn VB 2008 easily in less time.
View 2 Replies
May 3, 2011
I have a VB.net CF app connecting to a SQL 2008 server. I'm trying to implement transactions but when i break my code at the start of a transaction certain read queries cannot be done on the table. For instance selecting all records from the table where id <> 123 Won't return any values. But select * from stock will return all values except for the row I'm working on.
[Code]...
View 1 Replies
Sep 3, 2009
I want to create a log in that allow the user to select different level of access when there using the program. Ok here is how I want it to be the user must select either user or admin, along with typing in there password and username, but I'm a bit confuse in putting the coding together.
View 1 Replies
Jul 5, 2010
been banging my head on this, i need to get the applications path, then go up 1 folder then into another. As i have a main app and sub apps.
So were Application.StartupPath()is for example:"C: Main app folderSub app folder"How do i then go up a folder to"C: Main app folder"I Know it needs some string removal using on it but i can seem to get it right, after which i could then use Application.StartupPath() 'string removal here" & " ools"to navigate to another sub apps folder etc.
View 8 Replies