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?
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?
I'm tyring to pass a variable data type to a template class. Something like this:
frmExample = New LookupForm(Of Models.MyClass) 'Works fine
Dim SelectedType As Type = InstanceOfMyClass.GetType() 'Works fine frmExample = New LookupForm(Of SelectedType) 'Ba-bow! frmExample = New LookupForm(Of InstanceOfMyClass.GetType()) 'Ba-bow!
[Code].....
I'm assuming it's something to do with the template being processed at compile time but even if I'm off the mark there, it wouldn't solve my problem anyway. I can't find any relevant information on using Reflection to instance template classes either.
(How) can I create an instance of a dynamically typed repository at runtime?
I've got a program where the insert/update SQL was created with the values coded directly into the SQL string. I've changed this to use the Command's Parameters.AddWithValue method and all worked well. I'm now in the process of separating the data access code out into it's own class. I've got the Select code working using a DataSet in the form that I pass ByRef to my data class so it can populate or refresh it. My sticking point is in how to pass the parameters for the Insert/Update commands to the class since from the form I no longer have access to a Command object. Do I need to make the Command object in the data access class available to the form?
VB.NET is not letting me dance with both feet, or piss with both hands. I've got one foot and one arm tied behind my back at every turn. I want to use this statement in a function: Return CType(Formatter.Deserialize(FS), DS) Seems doable, right?
Function ReadFileStream(ByRef FS As FileStream, ByRef DS As Object) Dim Formatter As New BinaryFormatter FS.Position = 0 Return CType(Formatter.Deserialize(FS), DS) End Function
Right? I mean, CType only accepts a class name as the second argument. I can't give it an instance of a class, or it croaks. Yet if I try to pass the class name as the argument to that function: DataInfo = ReadFileStream(FileStream1, DataStruct)
VB.NET croaks on this, too, complaining that "'DataStruct' is a type and cannot be used as an expression.". It's used as an expression by CType just fine outside of the function. Does the VB.NET legislature provide a clause that allows for a 'Type' to be passed as an argument in a function? Writing all the supporting code ten million times to deserialize a file using CType ten million times in a large application will get very complicated and tricky very quickly. It should be handled by a routine so that any cases and adjustments that come up can be dealt with in one spot.
I am looking for a way to pass a class method into a new thread. On my form I have a few object that contain methods.
For example obj1.doWork.
Now I want to do
Example Dim t as new Thread t = new Thread(AddressOf obj1.doWork) t.start()
However I get an error on this saying:
Error1Overload resolution failed because no accessible 'New' is most specific for these arguments: 'Public Sub New(start As System.Threading.ParameterizedThreadStart)': Not most specific. 'Public Sub New(start As System.Threading.ThreadStart)': Not most specific.
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?
I am having trouble with a mySQL query with the .NET connector. When I create the query, it automatically creates my parameters as objects. I usually change the type to the correct type, which in this case is Date, but I get different results passing in the parameter as a date.When I do "Preview Query" as an object, I get the correct results, but bad results as a Date. I would just leave them as objects, but it errors out when I try to pass a date in.Here's the part of my query that I'm having trouble with:
(Tickets.Resolved >= str_to_date(@startDate, '%m/%d/%Y')) AND (Tickets.Resolved <= str_to_date(@endDate, '%m/%d/%Y')) AND (Tickets.Status = 'resolved' OR Tickets.Status = 'rejected')
I'm trying to pass data from the main form to a business class form for calculation.I have 3 types of cars and I can't get the code right to pass that to the business form. It seems correct to me, but obviously, it's not.This is the code for the calculate button, I can't figure out why its telling me that CarSize is not a member of the business form when I have it in the Enum statement at the top. I'm going by what the book says and this appears right according to it.
Dim CarTypeInteger As Integer 'determine the car size from radio buttons If LuxuryRadioButton.Checked Then
[code]....
In the book it says to specify the class name when declaring the enum on the business form. So to me it looks like it should be -RentalRate.CarSize.Luxury The error I have is 'CarSize' is not a member of the 'ChristiansCarRentals.RentalRate'.
I want to read data from xml into memory. My code works fine providing I only have one record in XMl file. If I have more than 1 record the program fails.[code]...
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:
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.
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.
I am converting some VB6 code which passed an unknown form object to a class, which then used the passed form object to reference the calling form and direct the data from the class as follows: The Called Class in the class clsGetRecord Public Function Execute(ByRef FRMForm as form) as booleanFRMForm.List1.Additem(SomeData)....Execute = SomeBool End Function The clsGetRecord is used by many different forms which receive data all have objects called List1 as: The Calling Form for the form frmThisFormPrivate function() as booleanDim objRecord as new clsGetRecordbRet = objRecord.Execute(frmThisForm) The passed form object which will receive dataEnd function. Is there any simple way to do this since the calling form object is unknown at design time?
I have written a class library that creates a dll to pass data back and forth within the same compiled instance exe. Is it possble to configure this Class Library in order to pass the data produced in the first instance of an .exe to other instances exe programs written in VB.NET?
My first thought was to add a Module. Older versions used Declare Files. Is there something in the compiler that I should set where the variables point to a specific memory address, or something..., that makes the variable available to other VB programs running in a seperate instance?
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..
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?
i have two form in vb form1,form2form1 contains button1,textbox1form2 contains utton2,textbox2form1 button1 contains code to show form2 myfrm2 As New Form2myfrm2.ShowDialog()
I need to pass a double from form1 to form2 and have form2 return this value back. My problem is while i can receive the proper value in form2 i can not seem to get the corrected value back in form1 (using byRef in form1). Here is the code snip
Dim AmountPaid As Double = 8 Dim newInvoiceRow As InvoiceDataSet.InvoiceRow If (MakeAPayment.ShowDialog(AmountPaid) = Windows.Forms.DialogResult.OK) Then
I have returned to a project I started a while ago. I have a small members database showing basic info (Title, Forename and Surname) in a data grid view with all data populated from a SQL database. I have the dataset populated with all this info as well as other data through the use of relationships/foreign keys (Addresses and Telephone Numbers, etc)I have tested the relationships using a simple form which shows the correct addresses, telephones, etc for each user as you navigate through it.
I now wish to show just the datagridview on form 1 which is read only with the row select set to full row (I have done all this so far). I have also set up a second form which displayes just the relationship data.I want to be able to load the second form (with the address and telephone number data, etc) when the row is double clicked by the user. ie - if row 15 is double clicked on, then the second form should load the address and telephone number data for record 15.
Form1 is a Datagridview which is non editable. I want a user to be able to double click and open Form2, which will allow editing BUTForm2 is a list view and also had a binding navigator so I guess I cannot use dialogue? I do not want to simply just edit in a dialogue and save.Is there an easy way to get the record from Form1 and pass it to the controls in Form2 so that the correct record is displayed?
I am trying to pass data between forms on a double click operation. On Form1, I have a simple database with three fields (ProfileID(PK), Profile First, Profile Surname). The database has 10 records at present which displays all records in a datagrid view which is set to read only. I have the Selection Mode set to FullRowSelect to highlight the full row.Form2, is a form to Display one record at a time. This form allows editing and saving of changes.How would I go about coding in vb.net to firstly get the ProfileID from the relevant row and send this into Form2 to display that record for editing?
I am trying to find way to design a report using my own custom class. I found links:
1.) How to work in Crystal Report with Object Data Source?
2.) Use .net object as data source in Crystal Report 2008
3.) Binding object with List<> to Crystal Report
4.) How to assign Custom class as datasource in crystal report
They were quite helpful, but I have been stuck in the first step while designing report as my custom class's property is not listed in field list of crystal report design view.[code]When I add my class objects to crystal report I do not get the usertype field from users class in field list.So how can I add usertype field to my field list? Or do I have to take another approach?The reason i wanted to use it as i am:
1.) Showing a form where user can type keyword 2.) program filters the records as per keyword using LINQ 3.) when user clicks the print button, I want to set the filtered records as datasource of my report
Imagine a project with couple of forms and a module. Now as per my knowledge if i want to send some data from one form to another then :
- If I declare variable friend/public in a module then it can be accessed in the entire project (thus also between forms). - If I just have to send data from one form to another, then I can call the other form's sub/function and pass value. - If the pass value by reference then I can get new value only if its changed in that function.
Now what the issue is, I need to pass a variable to a form and in that form when user types contents in a textbox or makes other selection and presses OK button then it should return some values back to the calling form. Now how can I achieve this (without declaring global variables which will be accessible everywhere) ?
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]