It is probably that I havenot created an instance of class, MyPoint.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MySrs As New MySeries(20)
MySrs(1).A = 10
anything wrong with using datatype object and determine datatype in class property? I have a typed dataset and it has several integers columns that are null in the db. and when I make a call it throws exception.is there anythign wrong with setting it as object in my dataset.. changing the throw exception property to Nothing and passing it to my property as integer?
for each row in myDS.DataTable cRate.CustID = row.CustID next row
and in my class
Public Property CustID() As Integer Get Return _custID[code].............
I have made a usercontrol, it has a property that has a PictureBox datatype. When the usercontrol is dropped on a Form from the toolbox, I want the picturebox property (in the property window) to be showing all the picture boxes (names) that are on the form as a dropdown so I cant select them. How do I do that?
I'd want a text box that at design time the developer can set a datatype property so only a value matching that datatype can be entered at runtime (e.g. If we made the datatype property of a textbox an integer then the user could only enter numbers into that textbox)In additiion I need a further property to replace ".Text". .Text always holds the entered value as a string, I want the new property to contain what has been written into the textbox but as the datatype that has been selected at design time.
Is there a way to change a base class type by Overrides or Shadows, or other meen?[code]...
In this example there is MyBaseClasswitch is the base Class, then ClassB that Inherits from MyBaseClass, and In ClassB I try to overrides the base property "MyColl" to change is type to a enum.
But it do not work, telling me that the base collection cannot convert to eCarBrand, blah blah blah
Is there other way to change base class type or other approach that a could use?
I have a very simple class that holds a few public properties - ID, Text, Colour, etc. and a Boolean called 'SelectedItem'. Just like the Checked property on RadioButtons, only one item can have its SelectedItem property set to True within a particular group. Note: there will be several separate groups (lists), each allowed to have only one item with SelectedItem = True.
My first thought was that I would probably just have to handle everything outside of the class, setting SelectedItem to False for every other item in a particular list when another item was selected. But that seems rather inelegant to me. So I've been trying to think of how this might be done within the class. For example: could I perhaps have a private string property called say "GroupName" - set in the New sub when adding a new instance of the class - and then use a private shared method to set every item's SelectedItem property to False, provided the item has the same GroupName as the newly selected item? I would have a go at doing this but I have no idea how to enumerate every instance of a class from within that class, or whether that's even possible. Is it? Or is there another (better) way to achieve my goal? Here is a cut-down version of what I've got so far:
Public Class ResourceItem Public ID As Integer Public Text As String[code]....
As can be seen: instead of instantiating a new ResourceItem and passing that as an argument to the manager's Add procedure, I'm simply passing the details of the new item and the procedure is creating the item from those. I don't know whether this is a good or bad idea - please advise - but I've done it because I couldn't figure out how to make the SelectedItem property only writeable by the manager, so I wanted to avoid having directly accessible objects that could have their SelectedItem property set to True without it deselecting all the other items in the same group. Of course that still leaves the possibility of setting a variable to one of the manager's list items and setting it from there, so I would still like to know how I could prevent that, if possible.
UPDATE: I didn't use the code above in the end, deciding instead to go with Cyborgx37's solution - which seems to work perfectly well for me despite the warnings about best practice. I also realised I would need to use the same class in another scenario where multiple items could be selected, so it was easy to add a Boolean property to the manager to enable that.
I'm using a 3rd party chart COM object (National Instruments CW graph) to plot data versus elapsed time.The x value needs to be a VB6 equivalent Date type which is a .NET DateTime datatype.What I need is a way to convert a TimeSpan datatype to a DateTime datatype.
Dim testTime as System.DateTime 'date Dim plotTime as System.DateTime 'date Dim elapsedTime as System.TimeSpan[code].....
I have a database in mysql. The column in table is of datatype time(0)
Similarly I have a control datetimepicker in vb.net I have assigned format property as custom to the control and the CustomFormat property as HH:mm:ss tt so that it can just provide the time. I dont want the date to be in it.
Issue comes when I try to retrieve the value from database I get an error as Converion of type 'Timespan' to type 'Date' is not valid
Try Dim myCommand As SqlCommand myCommand = New SqlCommand("select * from [HMS].[dbo].[DoctorSchedule] where DoctorID='" & txtDoctorID.Text & "'", Connection)
Public Class MyColorsClass 'Constructors Public Sub New() 'Empty Constructor
[code]....
However, if the empty constructor was called to instatiate this class then the colortype is not yet set. Therefore, if one accesses the 'IsColorCool' property it will always return 'False'. Now for the sake of this example, I must keep the empty constructor as part of the class.Now I could add some code in the 'IsPropertyCool' to check and see if a ColorType has been defined, and throw an exception if it has not been set, but I don't really want to do that.I also could always move the logic OUT of the property and into a method on the class called 'DefineIfColorIsCool' or something, and make the owness on the caller to make sure the method was called if they want to use the property 'IsColorCool'?
Public Class airplane Private var_num_seats As Integer Private var_num_engines As Integer
[code]....
Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?
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
I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]
This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.
Problem: A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent
Some example code (hopefully formatted correctly):
Code: '=========== Class Definitions ============= Public Class courseClass Public Class timeTableClass
I'm looking for a tutorial on how to Adding a list(of Class) or Collection as another Class's Property.What I am after is something like the Columns Collection for the DatagridView control.I would like to add Items in the graphics screen. Where the item list is displayed in the left panel and the selected Item properties are displayed in the right panel.
I have a class that has the following property that is generated by the methods in the constructor.
Public Class clsLoadTables Private _ds As New DataSet Public Property ds() As DataSet Get
[CODE]........................
My problem is that I do not want to inherit this class, but I have other classes that need to access the ds DataSet property. If at all possible I would like to not use inheritance and not load my datatable more than once in the program.
Here is my failed attempt to access the property inside another class that is not inheriting clsLoadTables:
[CODE].........................
How I can access this dataset that I want to load only once in the program from many classes without using class inheritance or a global module?
I know that an interface can contain another interface within it.But;can a class contain another class within it?Can an interface contain another interface within it?
I am working on a produce inventory database in my VB Express program.I have a form on the bottom and a spreadsheet at the top. I want to enter all the data in the form and have that data automatically transferred as a group to the spreadshet in the upper part of the page when I press a button.I know that there's an insert function.I set it up correctly. The problem is that I have to convert the textbox, which contain string data, to the datatype used in the database spreadsheet.HOw do I use CAST or do this?Here's the function I am using:
Evernything is a string cause the data is coming from a textbox, I need to convert it to the datatypes used in the database.Also how do I use the CAST and Convert functions
I have two classes, and for a property in one of the classes I'd like to be able to load it up with an array of the other class. However my attempt at accomplishing this results in a "Object reference not set to an instance of an object" error. I know it's a rookie mistake, but I'm stumpedssist?
My code is as follows: Namespace Parking Public Class garage
bare with me during this silly example. :-) Let's say I have a class like this:
Public Class Animal Public iLegs as int32 ' Number of legs Public bWings as Boolean ' Wings? Yes/No End Class
And another class that inherits the "Animal" class and adds one more property:
Public Class ScaryAnimal Inherits Animal Public iScariness as int32 ' 0-100, how scary is it? End Class
Now, if I have an instance of "Animal" with some values in it, and I decide I want to cast it to a ScaryAnimal for some reason, how do I do that without having to create a new instance of "ScaryAnimal" and copy each property value?Basically I'm looking for a way to do this, without having to write the lines marked with '*** below:
How can I get a string with the name of a property at run time?Obviously using GetProperty, as shown below, is NOT a solution since it requires knowing the property name to begin with:
Imports System.Reflection Module Module1 Public Class Country Public Property Capital As String Public Property Population As Long
[Code]...
What I want is to get the name from an instance (Nation.Capital for example) or from the type (Country.Capital).
I have created a very basic class for an object that has nothing so far other than a "name" property.
What I want to do is allow the User to add new properties to the class. Basically all the properties will be strings, but I would like to learn how to generally allow the User to create new properties for the class.
I'm currently writing a HMI for an automated machine in VB.Net 2010. I have a custom class that turns a Border green or red depending on the value of an input on a remote I/O module.
The connection to the remote I/O module is through a COM object provided by the manufacturer. I have three remote connections, lets' call them g1, g2, and g3. They're of type Manufacturer.ConnectionObject.
I would like to specify, using a property that I can set in XAML, that instances of MyCustomBorder use g1, g2, or g3. Unfortunately, setting up a Property called g and typing 'g1' into the property field results in the message "Property value is not valid. Details: Property 'g' does not support String to Value conversion."
[code...]
I need to implement a converter between String and the custom class, Manufacturer.ConnectionObject, but I have no idea how to accomplish this, especially since Manufacturer.ConnectionObject is part of a closed-to-me COM object.
Public MustInherit Class Entity(Of T As Entity(Of T))
And various classes derived from it. I would like to have another class accept all of the derived objects as a property, but I cannot seeem to find a workable syntax. If it were a parameter of a sub, I could say
Public Sub Foo(T As Entity(Of T))(TheEntity As T)
I can't seem to get that to work for a property:
Public Property E(Of Entity(Of T))() As Entity(Of T)
Gives me "Type parameters cannot be specified on this declaration"
Public Property E() As Entity2008(Of T)
Gives me "Type Parameter T does not inherit from or implement the constraint type ..."Is there an acceptable way to do this or am I stuck with using a Set Sub and a Get Function?
have inherited a Datagridview column called DatagridviewNumBoxColumn, I have added a property called FormatStringMy question is i want to access the property of format string value from another class.
Public Class DataGridViewNumBoxColumn nherits DataGridViewColumn Public m_FormatString As String