VB - Break Out Functions Into Multiple Classes?
Jan 13, 2011
I am integrating two disparate data sources where each value may depend on one or more other derived elements.This app runs as a windows service.Currently all my code is in a single class.I am upgrading to 2010 and wondering if best practices would be to break out my functions into multiple classes - there are over 100 data elements that need to be constructed. The following is an example of a couple derived items:(Is there a better way to do this - when complete I will pass this app off to someone else to support and want to make sure I give them the best beginning.[code]......
View 2 Replies
ADVERTISEMENT
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
Mar 12, 2012
I'm refactoring my VB project into 2 projects, one being a utility library that I want to share with future projects.My solution's layout is like this:[code].....
util is created as a class library, and the member files added into it. I've then added util into the main project's references.However, when I try to call functions in util.vb from my main project files, I get build errors like this:
error BC30451: Name 'LogException' is not declared.
error BC30002: Type 'VarFile' is not defined.
These are defined in util.vb, and it compiled fine when it was part of the main project. The declarations look like this: (I've trimmed out the details)[code].....
I can add util.vb "as link" into the main project and it will solve all the build errors, but that seems to defeat the purpose of refactoring out the class library - I would like to develop this library separately, and not always have to keep track of which file links I haven't added in my main project.
View 2 Replies
Mar 16, 2011
I have a Module in VB.NET called Math.vb and in that module, I created a Function that displays returns the percentage of one number to another. I have a Sub that calls the Function and I call the Sub from my Form1 class. Is there an advantage/disadvantage to putting the function in the class or the module?
View 5 Replies
Jun 22, 2010
The way my code is now its all basically in one class and I want to move different functions into other classes to organise it a bit.What is the best way to do this as I have been having problems I was just bringing in a new Main class when I needed to call the functions in my main class but this would give errors when I run the program and not let me run it?
Private mc as new Main()mc.functionNeeded But the error when I try to run"Stack over flow exception"
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
Any tips on how this is done. I couldnt find any info on it (probably because its so basic)
View 3 Replies
May 19, 2009
Is it considered an acceptable practice to use Modules instead of Classes with Shared member functions in VB.Net?I tend to avoid Modules, because they feel like left over remains from VB6 and don't really seem to fit in anymore. On the other hand, there doesn't seem to be much difference between using a Module and a Class with only Shared members.
View 4 Replies
Oct 31, 2009
I would like an overview of System.EventArgs. I have an understanding of System.Object where I can pass data between subroutines and functions using Public Classes. I am curious what EventArgs do?
View 3 Replies
Nov 18, 2009
[code]...
EDIT: The above class is just an example of what could be returned from a web service. I won't have access to modify it at all, sorry if I didn't make that clear.Is it possible to somehow make a clone this class, so that it retains all of the properties values, but hides the fact that there is a Public function?I'd like to be able to take some existing classes we retrieve from a web service(which we didn't write) and be able to pass them on for use in an application, but without exposing the functions. I don't want to go down the route of creating my own classes that specifically define each property and write the values in (due to the sheer size of some of them), so I'm looking to see if there is anything dynamic I can utilise (maybe there is a way using reflection?).
View 4 Replies
Jun 26, 2010
I want to know what are classes , objects , a namespace , subroutines,functions,methods,properties and differemce betweem byval and byref in your words.
View 18 Replies
Apr 8, 2010
I have text files with X Y Z data. There are three columns, one each for X, Y and Z and the files are tab delimited.The value of X is constant over a (repeating) range of Y. Z is the dependent variable.
For example:
0 1 44
0 2 32
0 3 22
[code]....
I need something to take this file and break into multiple tab-delimited columns. In the output, I would like the initial range of Y to be the first column (ie 1 to 4). Then, the second column should have the Z values for that domain (X=0 in above example). Then, the next column should have the Z values for the next domain of Y (i.e. 1 to 4 again, but now for X=5 in above example) and so on. Also, I'd like the first line value in each of the new columns containing Z values to be the X-value they were originally associated with.Thus, I'd like the output file to look like
Y 0 5 9
1 44 66 51
2 32 11 72
[code]....
View 2 Replies
May 11, 2012
So I have some vb.net code, and I have a nested For loop inside a For loop, and then I have EXIT FOR statement, will it break out of one loop, or the whole chain?
View 2 Replies
May 24, 2010
I'm trying to use transactionscope to maintain database consistent. But I'm getting error ('Already enlisted'). I'm using transactionscope in multiple functions. I'm trying to do something like this
Private Function RootMethod() As Boolean
Using scope as New Transactionscope
'Connecting & executing query.
[Code].....
View 6 Replies
Dec 6, 2010
What I am trying to do is have a class where the functions of the same name are both instance functions and shared functions.
Public Shared Function Get...(byval xx as xx)
and
Public Function Get...
The Public Function uses a Property xx created in the constructor, whereas the Shared Function has the parameters (byval xx as xx).
View 1 Replies
Sep 10, 2009
I downloaded a .net component that I would like to make consumable by COM clients. This component allows one to create a DXF file (Cad drawing). The problem is that the component is composed of quite a few class files, some inherit another. All the examples I found only show one file no namespaces etc. [Code]
View 1 Replies
Mar 19, 2012
I want to use this Structure in multiple .vb files within my project:
Structure MyStruct
Dim Name As String
Dim Good As Boolean
End Structure
If I define it in one file, the other files can't use it. How do I define it globally?
View 1 Replies
Jun 7, 2011
I have created a read-only property(name) in class1. How can I use this name property in class2?
Public Class Class1
ReadOnly Property name() As String
Get[code].....
Can I directly carry this name variable value into class2?
View 3 Replies
Mar 23, 2010
I am wondering the best way to store an object in memory that is used in a lot of classes throughout an application. We have multiple databases, 1 per customer. We also have a master table and each row is detailed information about the databases such as database name, server IP it's located and a few config settings.
I have an application that loops through those multiple databases and runs some updates on them. The settings I mentioned above are updated each loop iteration into memory. The application then runs through series of processes that include multiple classes using this data. The data never changes during the processes, only during the loop iteration.
The variables are related to a customer, so I have them stored in a customer class. I suppose I could make all of the members shared or should I use a singleton for the customer class? I've never actually used a singleton, only read they are good in this type of situation. Are there better solutions to this type of scenario? Also, I could have plans for this application to be multithreaded later.
View 3 Replies
Jun 21, 2009
I'm a long-time developer but semi-new to Visual Studio .NET and VB.NET. I've been working on an application for months, written in Visual Basic .NET. It's a rewrite of a popular IDE of mine that's originally written in assembly. What I'm trying to do in VB.NET is have multiple TabPage classes that inherit from TabPage, ofcourse, but each having it's own methods for common functions like Cut, Copy, Paste, etc. so that when I call tab.Cut(), the TabPage class for the currently-selected tab is the one used. In each custom TabPage class, I'll have a New instance of the main control that goes in that tab.
I think there would be a problem when I loop through the TabPages since the Foreach routine can only use one object type, as far as I know (TabPage).Currently I have only one custom TabPage class called Page that obviously inherits from TabPage, has additional properties and also methods that allow editing functions for whatever control is selected to be displayed for the tab. For example, when I call the New constructor, I supply the editor type as a parameter: dim tab as New Page(HEX_EDITOR).I have edit controls such as text, syntax editor, hex editor, bitmap editor, HTML editor, HTML browser. This means I get a new instance of all of those controls each time a new Page is added to the TabControl. I'm currently disposing of the unneeded editors depending on which editor is the one needed. The scheme is not preferred but it works great for now as I work on other areas of the IDE.
[Code]...
View 3 Replies
May 9, 2009
I have one class with <Serialize> attribute called Tree. And Tree class has an arraylist of TreeNode classes. Is it possible to use Soap to convert the Tree class and arraylist of TreeNode classes to one xml file or binary file? If it is possible, do i need to use <Serialize> attribute on TreeNode classes too? If not, what should i do then?
View 3 Replies
Jul 16, 2009
In a project of mine I'm currently doing this:
[code]...
all classes inherit docMain and addTemplateToList( X ) adds x to a List(Of docMain). Now my question is: Is there a better way to do what's done in the code sample? I thought of something like:
[code]...
Is this somehow possible in VB.net (Reflection?)?
View 3 Replies
Oct 26, 2011
Is it possible to have multiple classes in a namespace and be able to reference the functions within the clases if the Major class is instaniatated from another class?? for instacnce:
Namespace Database
Public Class Data
Public Class Prepare
[code]....
View 1 Replies
Jan 30, 2012
I'm still teaching myself how to bind and use observable collection. One problem that I'm a little confused on is binding multiple classes/observable collection to one page. In other words, if I have a PersonName class and a AnimalName class, I have to create two separate observalbe collections for each? How would I set the datacontext when a page only allows one?
[code]...
Now If I add another class, how would I combine the two on the binding part and collection part.
View 2 Replies
Nov 12, 2009
-new Dell laptop without a Break key.
-VB6 and VS2008 IDEs use Ctrl+Break to pause execution for debugging.
-I need a way to map another key combination to trigger a Ctrl+Break
My setup may make this easier or harder but to be clear I am running Kubuntu 9.10 (latest stable) and WinXP in a VirtualBox VM. Obviously all VB6/VS2008 dev is taking place in the virtual machine.So maybe it's possible to have the linux host send through Ctrl+Break based on a key mapping, or maybe it's possible to remap directly in WinXP. I'd settle for any solution as atm I need to use the XP On-Screen keyboard to send a Ctrl+Break.
View 11 Replies
Nov 21, 2009
The project requires a form that has textboxes for a students name and the amount of books they have read, and a label where the points they have earned for their reading is displayed. Also a seperate form with About information and yet another seperate form for summary information.
View 1 Replies
Apr 15, 2010
I'm trying to create a .dll in VB Express with multiple functions and subs.
For the .dll program, I create a class module with:
Public Class Class1
Public Function ReturnOne(ByRef MyVar As Integer) As Integer
[Code]....
Upon execution, it tells me that it cannot find the entry point in the .dll.
View 4 Replies
Sep 11, 2009
I am currently in the proccess of making a calculator, i have added all the functions i want, (+, x, / and - plus = obviously), but the problem is, i cannot do something like, "4+5x2", I can do "4+5" but i cant make 1 function mix with the others.
View 2 Replies
Jan 29, 2010
I have an asp.net web app. It has a shared class, and I want to have the connection string the same through out the site. My string is in my web config, but I don't want to type this all over the place:
View 3 Replies
Nov 6, 2011
Sharing similar functions across multiple controls
View 2 Replies
Mar 6, 2009
Okay, say I have a class named "ChannelList", and it raises an event named "FoundChannel"
But what I'M wanting to do is create multiple classes of different names that use that class, but I want to have all of the "FoundChannel" events be handled under one single sub routine?
View 15 Replies
Jul 26, 2011
I want to be able to incorporate some constant definitions and enum types in multiple classes of mine.Something akin to including a header file in C++. How do I do this best in VB.NET? I'm having a hard time because the only way I can see to do it is to inherit a class with the definitions in it but there is no multiple inheritance in vb.net so I am having some issues with that.
View 6 Replies