VB Classes Best Practice - Give All Properties Values?
Mar 16, 2010
Sorry if this is a bit random, but is it good practice to give all fields of a class a value when the class is instanciated? I'm just wondering if its better practice to have a constuctor that takes no parameters and gives all the fields default values, or whether fields that have values should be assigned and others left alone until required?
View 4 Replies
ADVERTISEMENT
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
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
Jun 3, 2010
I want to create a combobox that contains a list of items. I drag and drop a combobox and to the collection property I put the items.My items are all the months(January,February,March...) but i want to give to each item a value from 1-12 and I don't know how...do I have to create the combobox with code to achieve this?
View 10 Replies
Oct 21, 2009
I have Form Class A, which is the "Main Form". An Event fired by Form A instantiates Form B, and sets Form A as it's owner. (which makes it be on top of FormA at all times)[code]...
View 4 Replies
Feb 4, 2010
Accessing Properties Of Form Classes
View 1 Replies
Jan 12, 2011
Let's have three classes;
Line
PoliLine
SuperPoliLine
[code]...
View 3 Replies
Dec 3, 2008
Seems like you should be able to Suppress Properties in inherited classes. How do you do it?
View 7 Replies
Jan 9, 2009
what I would like to do is create a class that has a few private properties and one public property.the end result of the class is to return a list(of servers)below is what I am thinking. My brain just can't come up with the correct answer.
namespace sample
Private _servername As String
Private _farmname As String
[code].....
View 1 Replies
Dec 20, 2011
Simply i want to know why i can give some types values directly in the declaration, and how i can do the same thing with my own.As example:
Dim int As Integer = 11
Dim hex As Integer = &H1A
Dim str As String = "test"
[code]......
View 7 Replies
May 21, 2010
I have two custom attributes defined like so:
internal class SchemaAttribute : Attribute {
internal SchemaAttribute(string schema) {
Schema = schema;
[code]....
I would like to restrict the SchemaAttribute to classes, and the AttributeAttribute to properties.Is this doable?
View 2 Replies
Feb 27, 2009
I am a vb.net newbie, so please bear with me. Is it possible to create properties (or attributes) for a class in visual basic (I am using Visual Basic 2005) ? All web searches for metaprogramming led me nowhere. Here is an example to clarify what I mean.
public class GenericProps
public sub new()
' ???
[Code].....
View 3 Replies
May 26, 2009
You know how everyone says "C++ is like C with classes"?How similar is it to .NET classes? instance a class, based on other classes, add new properties, override existing properties, etc?Are the variables strongly-typed and declared before they are used? Or is it a Duck-Typing language like Python?
Also, does it have its own Garbage Collector that disposes of objects when the pointer exits their scope,or do you have to manually clear and get rid of them when you finish with them? What's the difference between native C++, and the "managed C++" in Visual Studio? Because I'd prefer to use native code if its not too much harder. for the sake of all that is good and holy, don't use ACCESS, EXCEL, or a TEXT FILE as a database. If you want your program to use a "local database", without any of the hassle of setting up a MS SQL or MySQL server, just click this link: >>> SQLite <<< Seriously. This is for your own good.
View 3 Replies
May 27, 2010
I am working on a bitmap class module in Visual Basic 2010 that has an option to create a graphic grid on the bitmap.
[code]...
View 3 Replies
Feb 15, 2012
what's a Class, and Object, a Method, a property and thins like that, but I have this doubt:Let's supppose I have a class "Laundry" this class has (just for this example) 3 propierties:
1.- laundryID
2.- Name
3.- Washers
Id and Name are "primitive" types or simple types (integer and string), but Washers, represent a list of object of type "Washer", that has 3 properties:
1.- washerID
2.- laundryID
3.- capacity
4.- brand
All of them (for this example) simple/primitives types (integer,string,string).So this my dilemma, it is correct to have a constructor like this (VB .net)
public sub new(ByVal laundryID as integer)
'' Here I'll query for the data of the Laundry on DB
'' After that I will query for every washer that belongs to this laundry
[code]....
And inside of that constructor query for all the washers that belongs to the laundry with id=laundryID parameter, and create objects of type "Washer" and add them to the list of Laundry ?I'm not sure If I explain myself, any comment I'll be really grateful, in less words, what's the correct approach (or good practices) to work with class/objects that has properties which are complex (other class/objects).I usually work with ADO.net probably ADO/LINQ/Entity solve this thins in an transparent way, but if they do it I don't really know it.
Note: I'm familiar with VB.net, C#, PHP, so if you prefer explain/help me using examples with its syntax, it's ok
View 2 Replies
Aug 8, 2011
Background:I have a base class and several inherited derived classes. The derived classes don't always need to have the same properties. If any properties are shared among the derived classes, those properties would live at the base class level ('Contents', for example).Similarly, GoodDocument below has 'GoodThings' but would not want/need to have 'BadThings'.I want to treat instances of both 'GoodDocument' and 'BadDocument' as type 'Document'
public mustinherit class Document
public property Contents as string
public sub new()...
[code]....
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
May 5, 2011
Im having problems passing values from my class "client" to display on my main form in text boxes. Im looking up a user input number and then pulling the clients first name, last name, and phone number from a text file. I figured out how to pull the information from the text files, but now im having difficulty passing the values to display in a another forms text box. This is what I have so far.[code]....
View 11 Replies
Jun 25, 2010
This is more of a conceptual question than anything.
I have a base class called "RawReader".
It sets up the framework for classes to inherit it and read in specific data systems.
For example, I want an app read in a known format of FoxPro database, a CSV file, or a SQL database (there is about 8 more formats currently), then transfer it over a webservice and create a SQL database from it.
I have everything working with CSV, FoxPro, Access, Excel, etc... Easy enough.
The classes that inherit RawReader, like RawCSV, RawFoxPro, RawAccess all return a struct that contains a dataset as one of the members. The dataset contains the data from the raw system. The webservice receives this struct and creates sql tables and loads the data into it. This has already been coded and works great.
My issue now comes to reading in SQL. Obviously, I could follow the same path, read the remote SQL DB into a dataset, transfer the dataset as above, etc... My "issue" comes in where I feel like it doesnt make much sense to transfer a SQL db to a dataset, transfer it through the webservice, and then try to programmatically recreate the SQL database. I feel like I lose a lot of the granular details from the SQL database (field sizes, extended info, etc..) It seems easier in practice to just create a backup of the database, convert it to a stream object and transfer the backup over to the webservice. But this is where the problem lies...
Since all of the classes inherit from the base class, they are set up to return a DataSet. The hack-ish way would be to just add a stream object to the return struct and in my webservice add other code to make a special case for SQL sources, but I was trying to avoid that.
Any thoughts on the "proper" way to go about something like this?
View 1 Replies
Sep 2, 2011
I'm still learning so this might be completely wrong. I have built a multi-user web application for internal purposes. I have split my code up to make it more manageable and have run into some problems. I suspect that I have done something very silly!
I have a class in a separate file (quoteStatus.vb) in App_Code here it is:
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data
Public Class quoteStatusHelper
[Code]...
This seems really wrong, as the value seems to be held in the partial class after the first run. So if I have two users accessing the class the public shared dim is changed for both users! There must be a better way to do this. I have looked everywhere and I'm more confused now than when I started off..How can I make QuoteStatus in the partial class unique to every user and access it from my code.
View 2 Replies
May 5, 2011
Im having a hard time trying to pass the values from a list inside of a class. Im trying to display multiple lines of values from a list inside of a class. My "client" class stores multiple lines of values into a list(of class transaction), with the number value(num) counting each transaction that it adds to the list.
Code:
Public Class Client
Private m_tranlist As New List(Of transaction)[code]....
im trying to display each line that is stored in the list in a label, and im having major trouble. I know all of the results are added into the lists, but how do i call the list in my main form in order to display each line of all of the values? Would I have to look up an index or something?
View 1 Replies
Apr 30, 2010
I'll get straight to my problem - I'm currently coding in Visual Studio.I have a table (countries) with the columns ID | Name. The table is filled with around 28 records.I also have a form with 4 combo boxes (set up as 1,2,3 & 4) that I want the user to select. These combo boxes will display the names from the table countries. I then want to use the selected names in the combo boxes to Insert into their corresponding ID into another table. For example England would have the ID 1, USA the ID 2 etc.So, is it possible to have separate combo boxes that will give separate ID values but using the same table? At the moment I can't seem to find a solution.Eventually the form will have more than 4 combo boxes so I don't want to use separate bindingsources for each combo box.
View 5 Replies
Oct 7, 2011
I am trying to implement a sub-class as a property of another class. Eg:
[Code]...
View 9 Replies
Mar 11, 2011
i would like to assign my array vals to properties of my object.
like:
For i = 1 To 32
myClass.Prop_i = val[i]
Next
View 3 Replies
Nov 14, 2010
I am using a class to track if a user cleared their personal information found within some text boxes on a form. In the button click event to clear the text boxes I am creating a new object to the class and assigning true to one property value. Sounds simple until I try and submit the form with a different button, and create a another object reference that I use in an IF statement to check the property value for true. Every time the statement fails because the value being returned from the getter in my class is false.
[Code]...
View 4 Replies
May 4, 2012
I am programmer from some time only, I have certain doubts in fundamentals, could you please clarify on the following:Case 1:
[Code]...
Does case 1 and case 2 yield same result, I mean is a private value necessarily in there?, can we use property itself to use its own value in its Set and get statements?
View 2 Replies
Aug 10, 2010
i was wondering if we could assign variables into the values of attribute properties like say:
<System.Xml.Serialization.XmlType(namespace:="Result" + x)>
where x is a string with value "qwe" so basically we get the output:
<System.Xml.Serialization.XmlType(namespace:="Resultqwe")
View 4 Replies
Apr 13, 2010
Looking at the new VB 2010 features, I stumbled upon support for Auto-Implemented Properties.Since I'm working with C#, this seemed quite familiar, but I noticed that VB did add a feature I would love to have in C#: setting a arbitrary default value for the auto-implemented property:I really like the clean usage of auto-properties in C#. This would save us the effort of introducing a backing field and hooking it up to the property everytime we simply need a default value, thereby cluttering up the code unnecessarily.I was wondering why this wasn't introduced in C# as well? What could be the rationale for not doing this? Is a syntax discussion going on, or are there technical limitations to implementing this?
View 4 Replies
Jun 10, 2011
I created this function to remove vbCrLf from the values of properties in a Custom Class:(vTransaction)
Public Function ValidateTransaction(ByRef vTransaction)
Dim property1 As String
Dim value1 As String
For Each p As System.Reflection.PropertyInfo In vTransaction.GetType().GetProperties()
If p.CanRead Then
[Code]...
Throughout testing I can verify that vbCrLf is being replaced with a space as expected. When I re-examine vTransaction the changes have not been retained and the vbCrlf's are still there. What do I need to do to retain the changes being made to values in vTransaction.
View 1 Replies
Oct 2, 2011
I am learning vb.net and I am having trouble wrapping my head around the following... I can create several properties of a custom class and get/set values or I can create a method to set them all at once. If each property is going to allow read and write should I just make a method to assign values all at once? I assume that I am missing a very important piece here. Example: I can create 2 properties:
[Code]...
View 2 Replies