Lets say I have a application with these three items:
A startup form called form1
A class lets say Class1
A class lets say Class2
How can I access a method in class2 from within class1? For example in Class2 I have a method call AddToDatabase(sql as string) and in a method is Class1 I have a SQL statement that I want to implement.
Solution that didn't work: Initializing an instance of Class2 in form1 called myClass2 and trying to reach it using: form1.myClass2Initializing an instance of Class2 in New subrotine of Class1 and trying to call it through: myClass2
I am working with a class that I need to class when ever the end-user wishes to do so. The two events are called: Remove and Add, I don't know how to call them, at all. I am using the Call command, but to do avial!! They are inside the same Class, but they are two entirely different events, that need to be called at different times, during the execution of the program's processes..
When I am loading an Assembly dynamically, then calling a method from it, I appear to be getting the method from Assembly executing before the code in the method that is calling it.It does not appear to be executing in a Serial manner as I would expect. Can anyone shine some light on why this might be happening. Below is some code to illustrate what I am seeing, the code from the some.dll assembly calls a method named PerformLookup. For testing I put a similar MessageBox type output with "PerformLookup Time: " as the text. What I end up seeing is:
First: "PerformLookup Time: 40:842" Second: "initIndex Time: 45:873" Imports System
I have a class named State that stores a lot of data regarding the current state (status) of the program (like the user's name, has he saved his work, last color he was using, etc). Before I allow the user to reset the state of the program, I want to backup the entire contents of State in case the user changes his mind and wants to undo things back to the way they were. I'm not looking for a complete undo algorithm, just a way to copy the contents of one object to another object (of the same class).
Let's say I have a page Test.aspx along with test.aspx.vb.Test.aspx.vb contains a class name "TestClass". In that class I have method1(), method2() and method3()I need to be able to call one of those methods, but I can't hard code it, the method to be executed comes from a string.
I can't do Select Case StringContainingTheNameOfTheDesiredMethod Case "Method1"
Basically i've got a web service that i'm trying to put some kind of usage logging in. To do this i've created a class with a logging method. I instatiate the class on the service and then call the logging method in each of the web methods.
I have a .dll file (Interop.ACTMULTILib.dll) that I use to connect to a PLC. This .dll contains a sub called ReadDeviceBlock2(byval devicename as string, byval size as integer, byref data as short).My console application startup thingy is a module. When I call this method in my main it works fine, if I call it from another method that was called by main it works as well.However, it doesn't work when I call it from my Timer_Elapsed sub? I guess this has to do something with threads but I can't figure it out.
Module Main Private Timer As New System.Timers.Timer Private PLC As New ACTMULTILib.ActEasyIF Private DataSet As new DataSet
I have a project that has some VB code in it that I'm not allowed to convert to C#. I work in C# and not very good at VB, but I am needing to modify that VB code to use some C# methods I created.
For example:
C#: Code: using MGCIS2.Reporting; using CrystalDecisions.Shared;
[code]....
At this line in the VB code (Dim crv As New Tax.Reports.CrystalReportViewer(_rdbc)) it is giving me an error:Too many arguments to 'Public Sub New()'
I am having some problems calling the First() method of the System.Collections.ObjectModel.Collection(Of T) class. My front-end web application is VB.Net 3.5, and the data access layer is C# 3.5. Here is pretty much the sample code I have:
I have a form call form1 which is a mdi tab. Within form1 there is a datagridview and a button. When the button is clicked it will fire a method within form1 to update and repopulate the dgv.
Now my problem now is that I have another form call form2 which I load using .showdialog. Whenever I update the data within form2, it will fire method from form1 and update the dgv in form1. However the dgv doesn't seem to repopulate the updated data.
I've got some debugging code that looks like this[code]...
The purpose of this code is to output the name of the calling method. Now, I would like to output the FILENAME where the calling method resides. Is this information available?
I am using a .dll called Kiosk in my application which is resonsible for disabling some keyboard keys. I am doing like this... using Kiosk; public static Kiosk.Kiosk KIOSK = new Kiosk.Kiosk();
essentially I need to create a class that houses the methods and then call the methods in the form but I can't seem to find out what the right code is to call it. I think there may be an issue with the conversion from a double to a string.
This is what I have for the Class
Public Class Aircraft Dim Names() As String = {"A-747", "A-737", "C-150", "D-240"} Dim TakeOffVelocity() As Double = {250, 264, 270, 240} Dim Acceleration() As Double = {33.5, 44.2, 37.1, 51.9}
So after i add the values to the list, for example : element.ThirdElement() will have the value from attribute3 ("Send"). Also element.secondElement() will retain the value from attribute2 and so on.
I have a logging class that stores entries in a datatable dt. I then use SQLBULKCOPY to write that dt out to a sql table. Basic stuff. Problem is, I'd like to only call SQLBULKCOPY when there's say 50 entries in the dt. The problem is, what if I'm done (either intentionally or not, like if the code block that's using the log class throws an exception) with the logging object and there are still 15 rows in the dt?
I am writing a alternative to GDI, and rigth now i am working at a logging function. The idea is that while you use the class to draw, it will write a logg of what you have done, which can be used to draw it back later. In that way i would be able to store a drawing with weary little disk usage.
I'm not entirely sure what to call what C# does, so I haven't had any luck searching for the VB.Net equivalent syntax (if it exists, which I suspect it probably doesn't).
In c#, you can do this: public void DoSomething() { new MyHelper().DoIt(); // works just fine }
But as far as I can tell, in VB.Net, you must assign the helper object to a local variable or you just get a syntax error:
Public Sub DoSomething() New MyHelper().DoIt() ' won't compile End Sub
Just one of those curiosity things I run into from day to day working on mixed language projects - often there is a VB.Net equivalent which uses less than obvious syntax. Anyone?
I'm working on a base class right now, here's a basic rundown of it:[code]The problem is, in the Public Class bar example, some classes may implement MyInterface, and others don't. What I'd like to be able to do is have the sub New() in the structure in the base class "Foo" be able to tell if the class calling it (either the Base class, or the child class) implements MyInterface or not.
I have a DataGridView that is bound to a DataTable. I was using AutoGenerateColumns=true but I changed it to false so that I could manage the columns myself and then I started getting an InvalidProgramException in the event handler for DataGridView.CurrentCellDirtyStateChanged. When this event handler calls another method called CheckFilter() it throws the exception. It does not enter the method when I step through the code so the exception happens when the method is called. CheckFilter() is a private sub with no parameters. The exception message is "Common Language Runtime detected an invalid program". I am using vb.net with .net 2.0 and Visual Studio 2008 on Windows 7.
I have a treeview which i populate dynamically using an XML Datasource. The leaf nodes in the TreeView attempt to open a URL in an iframe within the page.This all works fine, but i would like the iframe to be hidden until the point the leaf node is selected.what event is triggered when the nodes are clicked?? I tried the SelectedNodeChanged event but this doesnt seem to get triggered!
While fiddling with my code i noticed that when i remove the NavigateUrlField="URL" from my code the tree triggers the SelectedNodeChange event, But does not Trigger if NavigateUrlField="URL" is put back in.