|
Thanks for all of your help,
pmarfleet wrote: If the method is defined as Shared it is a static, not an instance member of the class. The CLR will load an Type object for the class on the Managed Heap so that the method can be invoked. No instance of the class is created on the heap because an object instance is required to invoke a static method. Garbage collection does not apply since there are no object instances to be cleaned up.
...then why is is that a "Shared" function can still be referenced in the context of an instance member? Just as non-static members cannot be referenced in a static context, static members cannot be referenced in a non-static context....or at least, that's the way it's SUPPOSED to be...I don't know why VB devs would have the need to do something different than the rest of the world
Dim manager As Manager
manager.InsertTransactionHeader()
and
Manager.InsertTransactionHeader()
both execute identically if InsertTransactionHeader is declared with the "Shared" modifier inside the Manager class (example is quite contrived, but I think it demonstrates my point)
"I need build Skynet. Plz send code"
|
|
|
|
|
Alaric_ wrote: ...then why is is that a "Shared" function can still be referenced in the context of an instance member?
I usually code in C#, not VB.NET. You can't do this in C#. At a guess this is just syntatical sugar, a feature of the VB.NET language that is designed to make it more 'user-friendly'. Internally, the method will be invoked against the type and not the object instance, because this is where the code resides.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
In C# you get an error if you try to do that. In VB you only get a warning, which in my opinion is a bit weak.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
ok...so if "Shared" is actually static, then why is there a static modifier? That's just plain confusing. ...and if "Shared" is static, I would assume that you are allowed to declare a method as "private shared". Is this assumption incorrect?
"I need build Skynet. Plz send code"
|
|
|
|
|
Alaric_ wrote: ok...so if "Shared" is actually static, then why is there a static modifier?
Luc already explained this point in his reply. The Static keyword I believe is a legacy of classic VB. In other languages (including C#), static has a different meaning which is synonymous with the Shared keyword in VB.
Alaric_ wrote: would assume that you are allowed to declare a method as "private shared". Is this assumption incorrect?
There's nothing wrong with declaring a method as Private and Shared . It just means that it is a static method that can only be invoked by other members internal to that class.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: No instance of the class is created on the heap because an object instance is required to invoke a static method
I think this is kind of ancillary, because you guys have already given me the answer that I need(Thanks guys) ...but pmarfleet: I'm having a hard time following the logic you used in the statement that I've quoted.
Classically:
...A "Class" is a "Type of" artifact...as in you write a "Person" class in which you define the state
information and behaviors of all instances of "Person"
...an "Object" is an instantiation of a Class. As in "Person person = new Person()"
If an instance of a class(which is an object) is created not created on the heap, then how is an "object instance" (which I assume you intend to mean something other than the classical definition of "Object") required. ...Your statement is turning into a Russell's paradox
Russell's Paradox = (Y is a member of Y iff( Y is not a member of Y))
"I need build Skynet. Plz send code"
|
|
|
|
|
It's a typo. What he means is:
No instance of the class is created on the heap because an object instance is not required to invoke a static method.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I have an MDI project with, so far, 5 MDI child forms. One menu item on the main form, mnuWindows, is set as the MdiWindowListItem on the MenuStrip. Here's the puzzling behaviour.
Whenever one particular MDI child form, F_Import, is open, the form changes how the MdiWindowListItem drop down menu works. It doesn't matter which of the other 4 child forms are open or may be the active child, when I click on the MdiWindowListItem menu, F_Import immediately receives the focus and is checked on the drop down menu. Selecting another child from the menu gives that child the focus, but, opening the MdiWindowListItem drop down menu immediately places the focus back on F_Import.
When F_Import is not open, the MdiWindowListItem drop down menu acts as expected. When the drop down menu is opened, the child form currently having the focus is also the form checked on the menu.
I have not been able to identify any form or menustrip property that affects this errant behaviour. Nor has a search on the Internet revealed any related information. Anyone run into this issue before?
|
|
|
|
|
The errant behaviour stopped when I removed the word "Import" from the form Name property.
|
|
|
|
|
chalk it up to just being the nature of VB
"I need build Skynet. Plz send code"
|
|
|
|
|
Hi,
I have writen my own front-end for a carPC project and for a final touch I thought I would have an option to wirelessly update the MP3 shared folder on my PC when I am in the driveway.
Right, what I have done is set my home PC to a static IP address of '192.168.0.136' and a shared folder called 'mp3'
Here is a small bit of code demonstating what I want to do...
strHubComputerIP = "192.168.0.136"
strHubComputerMp3Folder = "mp3"
strRemoteDirectory = New DirectoryInfo("\\" & strHubComputerIP & "\" & strHubComputerMp3Folder & "\")
If strRemoteDirectory.Exists Then............
this works fine, but if I change the IP address to "192.168.0.135" or the 'hub' computer is off (the IP address can't be seen), the computer hangs for 2 minutes.
For example, if I pull into my drive and want to update, but my home PC is off, I don't want the computer in the car to hang. I want it to tell me that the IP address isn't found.
Hope someone can help, I've been working on my front-end for a year now as I've been saving up for the hardware. This is the last bit I need to sort out, then I can build the machine
|
|
|
|
|
Just incase anyone was going to answer this question, I have found a way of doing it.
Instead of using IP address, I use 'computer name'
strHubComputerName = "main-computer"
strHubComputerMp3Folder = "mp3"
strRemoteDirectory = New DirectoryInfo("\\" & strHubComputerName & "\" & strHubComputerMp3Folder & "\")
If strRemoteDirectory.Exists Then............
This only hangs for 2 seconds if the 'folder' isn't found. This is far better.
|
|
|
|
|
Plz am trying to use SMTP to send an email
the error is receive is "Operation Time-Out"
Thank sin advance
phatkin
|
|
|
|
|
Try posting some code, your post is rather vague.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Imports System.Net.Mail
Dim strTo As String = "abc@abc.com"
Dim strFrom As String = "abc@abc.com"
Dim strSubject As String = "First Email"
Dim strBody As String = "Testing"
Dim objMailMessage As New MailMessage(strFrom, strTo, strSubject, strBody)
Dim objSMTPClient As New SmtpClient()
objSMTPClient.UseDefaultCredentials = True
objSMTPClient.Host = "000.00.0.00"
objSMTPClient.Port = 25
objSMTPClient.Send(objMailMessage)
|
|
|
|
|
Nice code, but it does not necessarily answer the OP's question as to why they are getting a time out...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Odds are you have a network connection or server configuration issue. Hard to say, even if I saw the code, just because the server doesn't work for me, doesn't mean it shouldn't work for you.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am using datagridview in my form and it is bound to a datatable.I have a add button on the form which added a new row in the datatable.Now what I want is that when user click on the add button it should the cursor should go to the new added row.
For example if there are more than 20 items in the grid view and user click add button then it will be added at the last but it does not scroll to the last row.
How can I solve this problem?
Thanks in advance
|
|
|
|
|
Isn't there a SetFocus method you can apply on the currently selected row? If so, you get the index of the newly added row and do a SetFocus on it.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Thanks for reply.It does get the focus on the last row but if the last row is now visible in the gridview then the gridview should scroll to the focused row.
|
|
|
|
|
I am using Replace function to replace the occurance of a double Quote (") in a string. But it shows me error. Can anyone suggest how to achieve that. The code i am using is as given :
DocStr = Replace(DocStr, """, "``", 0, , )
Here I want to replace the " with ``.
Please Help. Thanks in advance.
Sekhar
|
|
|
|
|
As oppose to using """ try using the character code(34). As """ causes a problem (i presume) as " is part of the syntax syntax.
e.g.
docstr = replace(docstr,chrw(34),"``",0,,)
modified on Saturday, January 19, 2008 7:40:16 AM
|
|
|
|
|
You use double quotation marks to put a quotation mark in a string:
DocStr = Replace(DocStr, """", "``", 0, , )
But why are you replacing the quotation marks with something that looks similar to a quotation mark? I seems like you are trying to circumvent some characters because you don't know how to handle them correctly.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Yes I want to replace the double quotes from a string that I have retrieved. How can i replace the double quotes from a string using the replace() function.
Please Help.
Sekhar
|
|
|
|
|
Eh...? You didn't read my previous post, you just replied to it anyway?
Experience is the sum of all the mistakes you have done.
|
|
|
|