Passing An Object From Its Own Class
Jul 4, 2011
In a VB 2010 program we have two classes Aclass and Bclass.In Bclass we need all values of an Aobject.How could we pass the Aobject to Bobject?[code]Is there any VB entity that could be defined as including all the properties of a given class?
View 3 Replies
ADVERTISEMENT
Oct 5, 2010
I've got a main form (Form1.vb) where I created some controls (with the Designer).I've created a class myTextBox, inheriting from TextBox, in myTextBox.vb.In the main form, I call procedures from myTextBox. The issue is, those procedures use values from the Form controls. So the class doesn't recognise them as initialised.What's the best solution for this?I think I could pass the object itself as a parameter but doing it on each call seems a bitredundant and it thickens the code.Is there any way to access the Form1 controls and objects directly from the myTextBox.vb class?
View 6 Replies
Sep 8, 2011
I'm trying to setup a WCF web service to be consumed by JavaScript using JSON and jQuery.I've noticed that you can send JSON without a DataContract if the service method parameters match the naming structure of the JSON object:
<ServiceContract(Namespace:="http://foo.com/bar")>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
[code]....
View 1 Replies
Dec 8, 2009
I am making use of a 3rd party dll and am encountering some strange behavior in VB, which doesn't occur in C# Perhaps someone can explain what is going on. Anyhow, I am making use of a method in this 3rd party library which accepts an array parameter ByRef. The end result is the variable should remain null after the method call, but it is returning initialized for some reason.
[Code]...
View 2 Replies
Apr 26, 2010
I'm having a problem with passing on values from my data grid view to a textbox located in another form.[code]
View 2 Replies
Apr 22, 2012
Base class has one field to hold numeric balance value. With 2 methods that accept arguments for adding and subtracting the new input calculating new balance. Sub class has four fields dates, transaction, memo and amount.I have a deposit form, and withdraw form. Each time one transaction is entered it creates an object with sub class fields, then adds to the account collection. My problem is not understanding how to call the deposit/withdraw method and pass the current transaction amount back to the base class to alculate the new balance. Does anyone have any links to information/tutorials on how to perform something like this? As you can see with my code I have tried various different approaches without any success.
[Code]...
View 5 Replies
Apr 7, 2010
I'm sure there are several ways of achieving my goal but I am after opinions on what you think is the best option. I'm writing a vb.net application which (amongst other thinks) interfaces with media players in the home. Because there are different types of media playersI'm trying to structure it so each type of media player has it's own class which interfaces to a management class which sits on top of all the different devices types.
The device classes are responsible for discovering the phsyical devices and returning that information up to the management class. A device class may be responsible for monitoring 1 or more physical devices so..
[Code]...
View 1 Replies
Jun 7, 2010
I am utilizing a centralized class object that needs to call another class object. The program itself will do something like the following
sFieldValue = CentralObject.ObjectHandler(1, TestFunction, "FunctionVar,FunctionVar2,FunctionVar3")
In the central object I have a function
Public
Function ObjectHandler(ByVal ObjectType
As
Integer,
[code]....
View 5 Replies
Jul 10, 2010
I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:
newProperty1 - a new string property of the derived class
flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class
Code example:
Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......
Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.
Code example:
' property names are in the string array fieldNames
'baseObjQuery is an ienumerable of baseObj
'derivedObjList is a list of derivedObj[code].....
Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?
View 7 Replies
Apr 28, 2009
I seem to have problem with passing a collection/sorted list/ list of strings from one class to another.I am using property procedure to pass it, however nothing is sent to another class. There isn't any error messages either.[code]
View 3 Replies
Nov 8, 2011
I occasionally find myself passing this or Me to a child object. Such as this condensed real-world example...
Public Class Entity
Private mValidator as New EntityValidator()
Readonly Property IsValid()[code]....
I'm concerned about .Validate(Me).I get no warnings or Code Analysis violations, but it just feels wrong. I get nervous about infinite recursion and garbage collection.
View 2 Replies
Jul 10, 2010
I am creating a procedure and would like to know if I can pass the name of a property. I.e ComboBox1 so I can change the properties of that object. What I have done is create a procedure to populate a Combobox from my MySQL database. What I want to do now is populate the relevant Comboboxes without having to create a new procedure specifically for each combobox. I can create a procedure for each Combobox but the whole reason for procedures and functions are to minimize repetitive code and to make code easier to manage.
At the moment my procedure is ProcedureName(ComboBox1, "DatabaseName", "DatabaseField").
What I want to be able to do is do
ProcedureName(ComboBox1, "DatabaseName", "DatabaseField1").
ProcedureName(ComboBox2, "DatabaseName", "DatabaseField2").
ProcedureName(ComboBox3, "DatabaseName", "DatabaseField3").
View 5 Replies
Aug 6, 2010
Here is the structure that I have:
Friend Class StandardFormatFile
Friend fileType As String
Friend numberOfSeries As Integer
[code].....
View 3 Replies
Aug 18, 2009
I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.
[Code]...
View 1 Replies
Aug 14, 2009
how to pass arraylist value in to another class?
View 8 Replies
May 12, 2010
How do I pass a structure containing strings from VB.net to VB6. I can get an integer to work but not a string.
View 3 Replies
Mar 10, 2012
what i am trying to do is pass the values username and password to the Private Sub XMLReg. the username come from a textbox then is passed to Property newUserName() and password is taken from a textbox and passed to Property newPassword() but how do i pass the values of both to XMLReg() and where would i call xmlReg?
My code:
Private Sub getUsersDetails()
Dim userName As NewRegs = New NewRegs
userName.newUserName = txtUsernameReg.Text
[code].....
View 2 Replies
Jun 21, 2010
I am trying to create an list or an array of a class.Here is my "Ingredient" class that I am trying to create a list of:[code]In my "recipe" class, I am want to create a list (or array) and I am drawing a big blank on how to do it. Can anyone point me in the right direction?
View 2 Replies
Jan 19, 2011
I need to write a procedure which will allow me to set readonly attributes for certain objects, for example:My form contains two text boxes box1, box2.My sub procecdure will contain code which sets box1.readonly() = true, but i dont want to name the "box1" in the sub procedure but pass it as a parameter....I thought this could be achieved using :
private sub disableobject(byval inobject as system.object)
inobject.readonly() = true
end sub
View 7 Replies
Mar 6, 2011
I am having some difficulty getting my head around passing objects between forms and hoped someone might put me on the right track... I have five forms: frmMain, frmLogin, rmAdminMode, frmUserMode, frmUserMode, frmUserModeDeepThere are two main use-cases: admin mode and user mode.Admin Mode: As the project starts it runs frmMain. Clicking a button stops the autologin (simple timer) and will invoke frmLogin (using .ShowDialog). The user is prompted for the users' ID number (four digits) and pass-code (again four digits).frmLogin will query a back-end database to authorise or reject the login attempt (this bit is all working fine) and then return control to frmMain. If the user is a valid admin frmMain will then invoke frmAdminMode.
frmMain -> frmLogin
<- frmLogin
-> frmAdminMode
[code]......
View 8 Replies
Nov 23, 2011
On page one I would like to create an instance of a class as such:
[Code]...
Then on subsequent pages I would like to be able to use pOne and xOne. Since pOne and xOne are local to page one how can I use them in other pages?
View 2 Replies
Jul 19, 2011
Let's says I have a class called Customer :-
Code:
Dim Cust as New Customer("Fred")
I also have a function in a seperate class :-
Code:
Shared Function Example(Example As Customer)
How do I refer to the class itself from within itself? For example :-
Code:
' from within the Customer class, call the Example function
AnotherClass.Example(Me??)
View 11 Replies
Jul 4, 2012
I am making a new class that requires a lot of input information. Some of the properties need to be set to a default value, however I do not want to hard code them into the class.
What do you think would be the most efficient way to populate these properties?
I've been thinking of making a new class to hold all the default props and pass them as one object into the new class as a single argument but it seems kind of clunky.
View 2 Replies
Aug 19, 2011
I have the following code in Class B
FolderList.add(FolderCategory)
when i do a count it display a list of 25 items in the folderlist.Now i have a main class when i tried to use the following method
Dim MainClass as New ClassB
Console.writeline(MainClass.FolderList.count()) the value reflects as 0 items meaning is empty.i need to retrieve the arraylist from Class B using the MainClass to retrieve those items inside the arraylist.
View 7 Replies
Apr 30, 2010
Public Class Form1
Public Contestant As New ContestantClass
Public HighScore1 As New ContestantClass
Public HighScore2 As New ContestantClass
Public HighScore3 As New ContestantClass
[Code] .....
The problem I'm having is the first time I take a value, it gets inserted in the right section. The second time I insert a value, it inserts it in the correct place AND updates the previous value I inserted with the new value. So apparently when I'm doing:
HighScore1 = Contestant
It's pointing contestant AT highscore1 rather than taking the name, company, and score from contestant and then storing it in highscore1. How I can pass that info by value rather than by reference?
View 3 Replies
Sep 18, 2009
I'm having a little difficulty Setting the .text value of a Textbox in an MDIChild from a Subby in a standalone class.
I'm at this point:
[code...]
I know that the data exists because it displays in the Message Box ( MsgBox("first item = " & ds.Tables(0).Rows(0).Item("NameLast").ToString())) and the executes fine, but for some reason, I can't get the text boxes in LeadsMod2 (Open as MDIChild) to update.
View 5 Replies
Jun 17, 2009
I created a program a while back, in the traditional VB.NET way by drawing a bunch of forms. I have started playing around with creating the forms at runtime using classes. I have a placeholder form called frmStartup which merely calls the CreateLogin() sub from the CreateFormClass. The CreateLogin() sub creates a new blank form, then calls the grpbxLogin(), btnSave() and btnExit() subs from the FormElementClass which adds all the buttons and textboxes to the form. Within the FormElementClass, I have associated btnSave and btnExit with event handlers. These even handlers call subs from the DataProcessingClass. The event handler for Exit works just fine.I am having a problem with the Save event handler. Precisely, I don't know how to pass either the username or password from the Login form to the btnLogin_Click() sub in the DataProcessingForm. I have tried using Me. and frmLogin., but the program doesn't see either of those. If the Login form is an instance that is disposed of once another Sub is called, then it won't exist later on to call from. I have tried declaring variables and passing those along to btnLogin_Click, but no matter where I put it, the program doesn't see txtbxUsername.Text or txtbxPassword.Text. Not even from within FormElementsClass, which is were the boxes are created.Any ideas on how to pass variables in this case? I am not even sure what you would call this such as passing between classes, or passing between instances.[code]
View 9 Replies
Aug 11, 2009
dim myCollection as new Specialized.StringCollection
dim myFoundThings as new ArrayList
dim index as Integer
dim newResultMemberName as String
[code]....
This is part of some code that will run without user interaction once it's spinning away, and I need to create a unique object from some items found in a StringCollection, naming the objects using information found in the strings stored in that StringCollection.
View 2 Replies
Dec 15, 2011
I'd like to have something like:
[Code]...
View 1 Replies
Jun 15, 2009
i've created bunch of classes. i have webservices which reference these classes and contains the classes as parameters and return objects.when i call the weservice, i have to convert the class to the webservice object else i can type conversion error.is there a generic way to convert between these types without having to assign the values by hand?
for example
public class person
fname as string
lname as string
end class
[code]....
i would liek ot be able to call the web service and return the data type back and have a generic coversion instead of as above in stead of:
dim wsPerson as wsReference.Person = ws.getperson()
View 2 Replies