VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?
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
ADVERTISEMENT
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
Feb 26, 2011
I've been wondering if there is anyway to extend a sub of a base class in a derived class or subclass. To date, the only thing I've been able to find is overrides and overloads functions, but to my understanding these functions just ignore your base class's sub and just allows you to run the new one with the same name.
What I want to be able to do is:
CODE:
I'm not sure whether this is possible, or if I'd simply either make a new sub in my derived class that first ran the base's class sub or whether I'd override the base class and then copy and paste the old code.
View 6 Replies
Mar 1, 2012
I have about 100 websites that I am going to be accessing to scrape some data from (weather, time, etc). When I go to code these babies there will be an abundance of sub routines that I will be creating. They each are going to be accessing pretty much the same type of data.
Should I put them into a Class some how and acces them that way or should I just use Subs and then call them into the Document Completed section of my web browser to run the code? Still sort of confused on the whole Class vs. Sub Routine thing.
View 2 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
Oct 26, 2009
When you refrence a Function like this one:[code]You may want to be able to get more out of that, like this.[code]So how would I be able to add subs or functions onto a sub or function like that?
View 4 Replies
Oct 28, 2009
created class TestA. There is Sub mysub defined inside it. Now I want to use this Sub in other class. So far I did like this:
Dim oTestA As New TestA
Dim dblA As Double
dblA = oTestA.mysub
[code].....
View 3 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
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
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
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
Jul 14, 2011
I`m a beginner in programming and i`m having problems calling an instance of my nested classes. I`m using VB.net and my code is something like this
[Code]....
View 3 Replies
Apr 3, 2012
I have an original assignment that works fine, now I need to go back and make it into classes. I am not 100% how to do this. My issues are with calling the classes to be used in the main form, and what to put into the classes.
I will post the original working assignment and my understanding of the classes.
[Code]...
View 7 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
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
Jul 9, 2010
I Have just been watching a video on throwing Exceptions. Are you supposed to throw System.Exceptions from within your custom classes. to the calling code, Which other way can they communicate. I have read in several places it is bad practice to throw SystemExeptions.
View 3 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
Feb 1, 2011
I am porting an app from VB6 and I run into problems with references to functions and subs. Basically, let's say I have 2 classes added to the project, like this.
Public Class OOOOO
Public Shared Sub BBBBBBB(ByVal FileName As String)
...
Call CCCCCC()
Call DDDDDD()
etc.
...
End Sub
[Code] .....
I had to make the BBBB() shared to be able to call it from another function AAAAAA() from another class PPPPP. However, I get error on the references in the BBBBB(), that CCCC() and DDDD() have to be made also shared (so instead of 1 error I got number of errors).
When I tried to make them shared as well, I got tens and tens of errors due to other references of both variables and functions.
View 4 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
Dec 11, 2011
For the time being I have been using a Structure to store "people" (their name, gender, age, etc...), because I really love to refer to something like Mike.name or Caroline.age, so I could simply put Caroline.age += 1 anywhere in the code and here you go, Caroline is one year older. No more simpler.But because of how inflexible (compared to Classes) Structures appear to be, when I needed to iterate through all the instances I was forced to use a list or dictionary so I could use a FOR EACH ... NEXT block. That was resolved by you people in the previous post, but I'm having the problem that I couldn't use the elements of the list to change the original instance of the Structure proper... I mean, if I code something like this...
For Each thisperson As Person In peoplelist
If thisperson.name = person_selected Then
'person_selected is the SelectedItem.ToString of a listbox[code]....
Well, I thought that thisperson.teamleader and Mike.teamleader were going to be equivalent (when the IF statement was true, that is) but that doesn't appear to be the case. So right now I'm really hating Structures...But when I look into Classes... well, they have more flexibility, yes. You could construct a FOR EACH block without any other trick like the "on-top" list, and that it's very useful indeed, but (a big "but" IMHO) I lose that NICE feature that makes possible to write the name of one of them instances like Mike.age or Caroline. kills
I mean, if I wanted to add a year to Mike, well... there is no "Mike" in the first place. A "Mike" string could be a property for the class, but I cannot (or know) magically refer to him with the ease of a Structure, so when I want something so simple as Mike.age +=1 ...well, with a Class I'm simply clueless to how locate him and change ANOTHER property of him.I suppose I am doing something very wrong, because I cannot believe VBasic could force on you those two extreme philosophies...:
Classes = +flexibility -usability ???
Structures = -flexibility +usability ???
What I want to do is SO simple that I cannot believe I need to choose between the two.
View 25 Replies
Jun 28, 2011
I need some help with how to organize classes in VB.NET. I have a class called parent with methods for adding, deleting etc. But I also need a method that returns a list of all the parents, a list with parent objects. Where do I put this method? Do I put it in the parent class or do I need to make another class called parents?
View 1 Replies
Oct 16, 2011
I've seen people discourage other from using nested classes, because the make things more complicated and are evil and whatnot.But I want to know what possible justification there would be for using a nested class and if there are any possible benefits for using them(or structures for that matter).
View 10 Replies
Oct 21, 2010
Public Class Form1 Dim CharList As ArrayList Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click CharList.Add(TextBox1.Text.ToUpper)End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
[Code]...
View 2 Replies
Nov 16, 2011
For a class project (online course, no instructor handy to get a quick reply from -_-) we are to write a short program using classes and OOP to roll a pair of 6-sided dice 1000 times and count the number of times the total of the two dice is 7. Easy enough, and I've read over a few examples that people have written, but they don't seem to use OOP. I'm not asking you guys to do my homework for me, but I am terribly lost when it comes to using OOP. So far I understand that I should be using a Random() class object to determine the roll itself, and then maybe load each roll into an array and use a loop to check if each element is 7 or not, and then increment a counter? How do I set the range of Random() so my dice rolls are representative of a 6 sided die? It's all a bit overwhelming and I'm not sure what I should do next.
[Code]...
View 28 Replies
Feb 24, 2011
What are the best ways you guys recommend to search the MSDN Code Library. I know there have been several instances in searching for ways to do something, doing a long workaround, and finding out later that there was a built in class that handled the problem that I was working on much simpler.
So what are some of the ways you guys use to find tools, classes, etc. when coding. Or are you just that awesome already.This is kindve just a general tips and tricks question. Sorry if Im in the wrong forum mods.
View 2 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
Mar 30, 2011
I have a MDI application and a very complicated class there which populates its properties from a dataset derived from an external database. Each form, including child forms have to be able to access that class and use its properties thorughout the whole session.I don't know where to 'preserve' these property values within the application. I kmow many books etc. suggest not to use public variables but I really can't find a way to solve this other than to use a public variable (which is a list(of my custom class) in this case.
I have a separate class called PublicItems.vb and declared there my public variable as
Public Shared secuniverse As List(Of myCustomClass)Is there something wrong with the syntax because if I try to use the variable secuniverse in my main application class, I get the following exception:'sectoruniverse' is not declared. It may be inaccessible due to its protection level.
View 7 Replies