|
I want to draw icon in CheckedListbox. May you help me.
VitaminY
|
|
|
|
|
What is the difference between Directcast and CType?
Also is it better to use CType(MyObect, Integer) than CInt(MyObject) - does it get compiled to the same MSIL or is a helper function called in the Microsoft.VisualBasic.dll?
Jim
|
|
|
|
|
While DirectCast and CType are both used for casting, DirecCast can only case object to object they have a direct relationship (ie. inheritance ) with. For example, if B inherits A, and C inherits A, you can use DirectCast to cast a C object to A.
OTOH, CType can be used to cast from any object to any object. The advantage of DirectCast is that it's much faster than CType , so use it whenever appropriate.
Looking through the IL for CType and CInt , they're actually doing the same thing, so I assume there's no difference in using either.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
|
|
|
|
|
CType is more flexible because it's not limited to converting between standard types. It can be used to convert between composite types as well as converting an object to any one of its interfaces.
CType is also compiled in-line with the expression whereas the CInt is not. CInt calls a library function to convert an already evaluated expression result whereas CType code is actually compiled as part of the expression.
Now, DirectCast... The difference between the two is that CType succeeds as long as there is a valid conversion defined between the expression and the type, whereas DirectCast requires the run-time type of an object variable to be the same as the specified type. If the specified type and the run-time type of the expression are the same, however, the run-time performance of DirectCast is better than that of CType
Consider the following code:
Dim Q As Object = 2.37 ' Requires Option Strict to be Off.
Dim I As Integer = CType(Q, Integer) ' Succeeds.
Dim J As Integer = DirectCast(Q, Integer) ' Fails.
The run-time type of Q is Double. CType succeeds because Double can be converted to Integer, but DirectCast fails because the run-time type of Q is not already Integer.
Clear as mud?
RageInTheMachine9532
|
|
|
|
|
Thanks, that is a lot clearer.
Jim
|
|
|
|
|
I have two distinct .NET applications which must interact with one another. Some information from the first one should be passed to the second.
How can i do that ?
Thanks in advance for any ideas.
Ekaterina
|
|
|
|
|
Need a bit more detail about what your doing...
What are you passing between the apps and how much?
How do these apps interact?
Do they have to interact in real-time or can they do their processing in transactions and batches?
Do you have the source for both apps?
RageInTheMachine9532
|
|
|
|
|
Looks like the kind of thing you'd use "Remoting" for...?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
|
Duh! That would be the all-encompassing answer, wouldn't it!
My bad! Thanks!
RageInTheMachine9532
|
|
|
|
|
you could use session variables
application 1
save your value
session["id"] = txtbox1.text
application 2
read your value
dim strtest as string = session["id"]
there is another other option you could pass the value as parameter, it depends on your flow.
|
|
|
|
|
hi programmers,
i got something new in my mind... i want to hide some files or folder that are download from the internet such that they are not viewed by one, except some key combination or if he is under the admin rights for win2000/xp/NT etc.
|
|
|
|
|
How do you want to hide these files? Do you want to want to encrypt them so noone can see the contents? Do you want the files hidden in the directory, which is pretty weak security by the way...)? Need a bit more detail about what you want...
RageInTheMachine9532
|
|
|
|
|
Hello!
I have a little problem:
Example:
if I have 01/06/2003 and I want to add x months (example 3 months) and I want to obtain 01/09/2003 or to add days or years.
How I do this thing in Visual Basic .NET 2003?
Or how to convert the date to days and then to reconvert to date.
Please help me!
Sorry for my english!
Thank you!
|
|
|
|
|
Try this:
DateTime dt = DateTime.Parse("11/06/2003");
string dts = dt.AddYears(3).ToString();
|
|
|
|
|
I have a file which is seperated into fields by a comma
for each field. I am trying to read the file into some type of structure but am unable to get past the point of reading upto the comma and then
storing that away and then going back and reading the next field.
Any help would be appreciated.
|
|
|
|
|
For each line that you read in use split(',') on the string. The returned value will be an array of strings, each representing one field.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
|
I have broken appart the file by using the split function but now have an issue with the carriage returns. The values from the last field of the line is put with the first field of the next line?
|
|
|
|
|
ccandler wrote:
I have broken appart the file by using the split function but now have an issue with the carriage returns. The values from the last field of the line is put with the first field of the next line?
Now I'm confused.
You mean that each line of the file doesn't represent a full record, and that a record can overlap lines of the file?
Maybe you could provide some sample data and information about the file format? A straight CSV would be readable the way suggested.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
I use IcmpSendEcho func (from Lib "icmp.dll") to check 2^16 IP addresses for pinging, it takes too much time. Has anybody other decision? The program has to be written in VB. I tried to decrease PING_TIMEOUT parameter of this function(from 500 ms to 100 ms), but it doesn't decrease the programm runtime.
Thanks in advance
|
|
|
|
|
If your pinging all 65K address one at a time on a single thread, then yes, it'll take a long time to get through them. A faster method would be to write a multithreaded solution and launch, say, 100 pingers at a time.
If your using VB6, free threading is NOT a trivial task.
If your using VB.NET, free threading is MUCH MUCH (Hint! ) easier!
RageInTheMachine9532
|
|
|
|
|
can u send me the code
Thanks
|
|
|
|
|
Hello and hi
i want that on clicking a browse button
on a certain form , a word file is selected (usiing common dialog box)and then contents of word file will be displaced on
any of the object like (ole db etc.)
and using a save button i can store contents of that word file in to another file anywhere on the disk
tell me which object is more comfortable to use to show the contents of a Word Document and how ?
example required
ali baba
|
|
|
|
|
I declare a brush... Dim lBrush as SolidBrush
Then I use it lots of times in a function for different things like gradient fills. So I might do...
lBrush = new GradientBrush...
Then again...
lBrush = new GradientBrush...
You get the idea. Should I call lBrush.Dispose before I say lBrush=New brush....
If I don't, do I get a memory leak?
Sounds like a waste of time, unless you have an object that is going to be in scope for a long time using transient resources that should be released quickly.
Thanks 4 ur help guys.
Nursey
|
|
|
|