|
Experts please help.
Class parentctrl(Of editctrl)
inherits control
' ... code ...
End Class
Class mylistbox(Of pctrl)
inherits control
' .. code ...
End Class
Now the problem comes when I try to instantiate the class parentctrl providing it with a concrete class in place of the generic. there is an infinite nesting that is created. how do I overcome this.
Dim mycombobox as new parentctrl(Of mylistbox(Of parentctrl(Of mylistbox(Of parentctrl(Of mylistbox(Of parentctrl .... )))))) ()
Is there a keyword like "self" or something that can make the compiler understand that I have provided it enough information to do what i want. If one tries the above code out you will know exactly what the problem is.
|
|
|
|
|
Hi,
I have a DLL called by a client application. The call may occur twice, such that there are two instances running.
What I would like to do is in the New constructor of the DLL, have a routine to check if an instance of the library is already loaded into memory. If so, then the routine would return a pointer to the existing instance, rather than instancing it a separate time.
I imagine this a Reflection issue?
Can anyone help?
Thanks
AndyORS
|
|
|
|
|
Ex: All your code should call 'oclientapp' instead of using 'moclientapp'
Public Class Test
Private moClientApp as Object = Nothing
Public Function oClientApp As Object
If IsNothing(moClientApp) Then
moClientApp =CreateInstance("Client","Application")
End If
Return moClientApp
End Class
Private Function CreateInstance(ByVal sAssembly As String, ByVal sClass As String) As Object
Dim ao As [Assembly], aoName As New AssemblyName
Dim o As Object
Try
aoName.Name = sAssembly
ao = [Assembly].Load(aoName)
o = ao.CreateInstance(sAssembly & "." & sClass, True)
Catch ex As Exception
'ExceptionManager.PublishException(ex)
Throw ex
End Try
ao = Nothing
Return o
End Function
-- modified at 12:07 Wednesday 15th November, 2006
|
|
|
|
|
Hi,
Thanks for your explanation - however I'm still unsure how to apply your code. May I ask you to elaborate perhaps by using the following as an example:
My code might read:
Imports MyLibrary
Public Class Form1
Public ins1 as new MyLibrary
Public ins2 as new MyLibrary
End Class
Thanks,
Andy
|
|
|
|
|
Sorry must of been confused...
The class itself can not do that unless you also give the first pointer to a global/shared variable because the class does not know how many instances of itself have been created. So my code would come into play checking the global/shared variable to whether or not it's nothing.
Your idea of the constructor would not work either. The New event fires when the instance is created. You cannot return a different pointer from the one your are creating. You need to check the variable holding on to the first pointer to see if it's populated or not.
Your example:
Public ins1 as nw Mylibrary 'the pointer of this instance is the only thing that can be return into ins1. the new cannot return a different pointer.
Nathan
|
|
|
|
|
Hi,
I have created a small utility which reads in the contents of a text file, and puts the contents into a datagrid.
The datagrid has 3 columns; 1 = Product, 2 = Quantity, 3 = Value
The product will appear more than once in the datagrid - which is unsorted.
What I want to do is work my way through the grid, and perform a check calculation on all of the Quantities and Values stored against that particular product.
A very simplistic example of the data in the grid might read as follows:
Product3, 5, 2000
Product1, 10, 100
Product3, -5, -2000
Product2, 1, 50
Product2, -1, 50
Product1, -10, -100
The calculation I want to perform is to check the Quantity and Value for each product (Product1, 2 and 3 in this example), and determine whether the nett value is zero (for example, the first Quantity for Product3 is 5, and the second Quantity for Product3 is -5, so the nett is zero). If the value is not zero, I want to add that product to a listbox to summarise where the errors are.
The number of rows in the datagrid may be many thousands - I've even heard rumour that it could be hundreds of thousands (though I've not seen any evidence of this yet )
|
|
|
|
|
You can use a Dictionary Of(String, Int32) to aggregate the products and quantities. Loop through the grid and check if the product exists in the dictionary, and add or update it.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for your reply.
Looks like I need to do a bit of research. I've never used Dictionary before.
Could you post a snippet of code? It would help me to learn how I could use it in my utility.
Thanks.
|
|
|
|
|
hi all
i have a set of data in hyperterminal of my system which is automatically coming to the hyper terminal when i connect my pc to a epbax system.
now the problem is i want to insert those data to access database automatically when any new data comes to the hyperterminal using vb.net
can anybody help me in this regard with suitable code snippets..
thanks in advance
i m pradip kishore from india,working in vb.net & asp.net
|
|
|
|
|
You can't extract data from HyperTerminal. It doesn't expose any method of communicating with another application. The best way to do what you want would be to write your own serial comm app. That will get you the greatest flexibility and easy access to the data comming through the serial ports.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanks for ur response
my objective is.. when ever an EPBX will be connected to my pc,then the call details(like calling no,call duration etc..)will come to the hyper terminal of my pc automatically.bt i want a way by which i can insert those data to any of my access or sql server database for further manipulation through program(vb.net) based on the received raw data..
can u give me some sample code snippets or some links regarding this..
thanks in advance
i m pradip kishore from india,working in vb.net & asp.net
|
|
|
|
|
One more time... You can not use HyperTerminal in your program in any way shape or form!
You have to write your own code to handle the serial port and get the data from it.
VB.NET 2005 makes this pretty easy with the System.Io.Ports namespace. VB.NET 2002 and 2003 will need to use a 3rd party, or home grown, class that exposes the serial port to your code. A quick Google for "vb.net serial port"[^] comes up with lots of examples.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi
thanks for your help
i m pradip kishore from india,working in vb.net & asp.net
|
|
|
|
|
i have a problem like i would not like my user to type in the same thing over and over again. What i would like to do is tt if the user type something in the textbox, my textbox is able to save the statement. So in future the user who wants to use the program again can just click on the dropdown arrow and select the text and not keying in everything again. Any solution to tis??
|
|
|
|
|
You need to write the code to store it somewhere. A textbox isn't going to do that, and it's the wrong place to write the code to store your information. Where do you want to store it ?
Christian Graus - C++ MVP
|
|
|
|
|
Also, it appears you want a combo box, not a text box. Probably you want to store past choices as Xml, I would suspect.
Christian Graus - C++ MVP
|
|
|
|
|
Currently in my application i am using textbox. wat i mean is if the user type in for example 'myproject.com.sg' and tis phrase wil be save and the next time the user will not have to type in anymore but can select from a dropdown arrow. i am doing sumthing like combo but as i know the variable we have to preset ourselves and it is not fexible. What i need to save is wat the user type in and i cant hardcode wat they ared going to type.
|
|
|
|
|
OK, so do what I said. Use a combobox and store the text that is entered to an XML file.
Christian Graus - C++ MVP
|
|
|
|
|
how to?? i do not know how to use XML. Do u have any example of wat should i do?
|
|
|
|
|
I am going out. A DataSet can save/load XML, or you can use an XmlDocument.
Christian Graus - C++ MVP
|
|
|
|
|
still dun understand.. Any site whereby i can refer to?
|
|
|
|
|
mystring = text1.text //store what they've entered in a string
combo1.additem mystring //store what's in the textbox in a combo
next time user uses the system they drop down the combo to find their item and don't enter text in the text box
|
|
|
|
|
Subjugate wrote: Any site whereby i can refer to?
This one. There are plenty examples of how to use XML if you search the articles.
|
|
|
|
|
You can also use SQL or Access to store the input data. Although I suspets it would be slower than going the XML route. But if you have no experience with XML this may be the way to go.
It should be fairly easy. Just create a SPROC that updates the table after each entry and on page load fills a dataset that populates the comboBox.
I know I was really broad but you can find hundreds of sites on how to accomplish this. Good Luck.
GT
|
|
|
|
|
Hi,
I have created a report using TTX file. If i preview the report the sample data in TTX file is not displayed. Instead it shows '1' as default value for the number fields and 'string sample value' for string fields. Please help to solve this.
Thanks,
Ramesh.
|
|
|
|