|
AAGTHosting wrote: The database stores both the time and the date 1/1/1900. Then with the following code I convert it to dateTime because the info is in a dataRow. Does this help?
None of this makes any sense, so no.
You created your own datatype, inheriting from DateTime?? May I ask why and what the implementation looks like?
|
|
|
|
|
The code is equivalent to:
startTime = startTime + startTime.Add(timeInterval)
As you see, you are trying to add two DateTime values. There is no operator overload for the addition operator that does that, so the compiler tries to convert the values to types that can be added. The only conversion that gives data types that can be added, is converting them to String s. Therefore the compiler assumes that you are trying to do this:
startTime = startTime.ToString() + startTime.Add(timeInterval).ToString()
However, as you are using Option Strict On , implicit conversions from DateTime to String is not allowed.
The statement is illogical. Is it not this that you are trying to do really?
startTime = startTime.Add(timeInterval)
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Good evening All
I have found a new job and they want me to Stop vb.net and move to C#. well i have done C++ and Java in my Academic days and never used it again, and now that Pain world comes in again. i have never used C# , in VB.net we drop controls to the forms and start code behind the Control using different Events, in C++ its a Pain to Create a Form in old Java JDK 1.2 its realy a pain to design a Form, because you had to align the Controls in the pane. So what i want to know is that , If C# is a .NET language, do you still Drop a Control and Code its Event ? or its still a Pain of Creating UI ? and a lot or Arrays declaration, Threads ?, Cant i design my logics in vb.net and Allow a C# developer to Access those Logics ? cant we be on the same team but using different languages? is vb.net going to Die? What is it, that is in C# that we cannot do in vb.net? Cant vb.net do handle security ? are they not .NET languages ? on the Same PlatForm? is there a realy a need to move from vb.net to C#?
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Writing forms etc, in VB.net or C# is more or less the same. The syntax in C# pushes you to write slightly neater code, to my mind, but essentially there is no difference.
|
|
|
|
|
The reason to move is simply that you cannot write an application in mixed languages. So, you have to conform to your team. The differences are mostly just syntax, everything else works the same. I don't use VB.NET ( I hate it ), but I answer questions here all the time, because my knowledge of C# translates easily to vB. I just hate the syntax.
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 )
|
|
|
|
|
Vuyiswa wrote: I have found a new job and they want me to Stop vb.net and move to C#.
Good for you.
Vuyiswa wrote: If C# is a .NET language, do you still Drop a Control and Code its Event ?
Yes, you actually use the same designer as with VB.NET. It's just the language in the code file that differs.
Vuyiswa wrote: Cant i design my logics in vb.net and Allow a C# developer to Access those Logics ?
If you work in separate projects, it would be possible to use different languages, but I wouldn't recommend it. I don't think that your boss wants code in different languages, code maintenence is hard enough as it is.
Vuyiswa wrote: is vb.net going to Die?
Sadly, no.
Vuyiswa wrote: What is it, that is in C# that we cannot do in vb.net?
Actually very little, as they use the same framework.
Don't fear the C#. It's actually a quite nice language. If in the end you find that you still like VB.NET better, you will have gained a better understanding of the framework and programming in general, so you will have become a better VB.NET programmer also.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks guys for Advice
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I'm looking at someone else's code and noticed that they have placed a Dim statement inside a loop. What is the impact of doing such a thing ?
I'm used to declaring all of my variables at the top of a function/procedure and not anywhere else in the code. (Just my preference - Old school)
Here is a snipet of code:
For i as Integer = 0 to ref.Length - 1
DIM STAT AS INTEGER
< ... lines of code removed..>
STAT = Cint(ObjProperty("STATUSIND","FORMULA",ref(i)))
<... lines of code removed ...>
next
Thanks,
david
|
|
|
|
|
There is no performance hit. It's actually faster than if you put "STAT = 0" in the same spot and put the Dim outside the loop.
|
|
|
|
|
I am more concerned that by having a "Dim" statement inside a loop that it would cause some excessing memory usage or potentially a memory leak. Initially, I wasn't concerned about performance. Thank you for your quick response.
|
|
|
|
|
Dave Kreskowiak wrote: It's actually faster than if you put "STAT = 0" in the same spot and put the Dim outside the loop.
You are comparing code that is not equivalent. The variable is initalised to zero only once, regardless of where in the code it's declared. Where the Dim statement is placed only affects the scope of the variable, the generated code is exactly the same regardless if the variable is declared inside or outside the loop.
Example:
Dim s As String = String.Empty
For i As Integer = 1 To 5
Dim x As Integer
If i = 3 Then x = 1
Console.WriteLine("{0}: {1}", i, x)
Next
The output:
1: 0
2: 0
3: 1
4: 1
5: 1
As you see, the variable x is initialised to zero eventhough it's not assigned any value until the third iteration in the loop. Once it's assigned a new value, it retains the value for the remaining iterations, demonstrating that the variable is never re-initialised.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Crap. The effects of getting 4 hours of sleep a night for the last 2 months...
|
|
|
|
|
Hi Friends..
I need to bind the dataset return value to excel.The thing is ..if i bind to a datagrid and then if i import to excel it works..But what i need is to bind the dataset directly to excel without the intervention of datagrid..Someone help in this regard as early as possible.
Thanks In Advance..
Balaguru
|
|
|
|
|
You can't bind an Excel worksheet directly to a DataTable in .NET. Excel doesn't know anything about .NET classes so can't directly interface with them. You'd have to build the worksheet cell-by-cell from the DataTable. You can checkout this[^] and this[^] for examples.
|
|
|
|
|
Hi all,
How can use the IN Operator with Parameters. Any Example will be helpfull
Thanks
Dana
|
|
|
|
|
Hello Dana,
The values that do not fit into a neat range, we use the IN operator. An example would be:
Select * from Customers
Where CustID IN (1, 3, 5);
The above query will give us rows for CustID 1, 3 and 5 from the Customer's table.
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Thanks for the post Dave Traister,
How can I implement this using Sqlcomamnd.Parameters object
Regards,
Dana
|
|
|
|
|
Hello Dana,
Try the following:
Dim commandText As String = _
"Select * from Customers
Where CustID IN ( @ID);"
command.Parameters.Add("@ID", SqlDbType.Int)
command.Parameters("@ID").Value = customerID
Dim rowsAffected As Integer = command.ExecuteNonQuery()
The link below shall give you more information but it does not use the IN operator:
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Hi,
I am customizing the datagrid view columns in windows application.That is not successful to me.How to generate particular table values in the datagrid view control in customizing manner.
Regards,
vidyashankar.T
|
|
|
|
|
You didn't say what you're having a problem with. Are you creating your own DataGridViewColumn implementation from scratch?? Are you inheriting from another DGVCOlumn type?? Did you create a custom editing control for this column type??
What you're asking is way too large of a topic for a direct answer in a forum post. Given the vague scope of your question, this[^] is about the best information you can get.
|
|
|
|
|
Hi,
I have a Async socket receiving app and a sending app, the receiving app works great. The problem is when i'm sending something with the sending app ( begin connect -> endConnect, BeginSend - >EndSend) The begin send callback which on the first line does:
private sub beginSendCallback(byval ar as iAsyncResult)
socket.endsend(ar)
end sub
' This callback method is called in a matter of seconds, but the 'file has about 3-4 MB, and the sending isn't near to completion, I have a list of IP addresses in which to send the file, but because the sending to the first IP address isn't finished, although the callback method is called it moves on, and of course creates an error later in the program...
So how do I stop the callback method from calling itself until the file transfer is complete, or how to somehow know when the file is completely transferred.
Thank you!
|
|
|
|
|
I added the line of code option strict on to my program and I noticed that I got a lot of errors about not being able to convert from decimal to double, etc.
When should I use option strict on?
|
|
|
|
|
Hi,
Visual Basic allows conversions of many data types to other data types. Data loss can occur when the value of one data type is converted to a data type with less precision or smaller capacity. A run-time error occurs if such a narrowing conversion fails. Option Strict ensures compile-time notification of these narrowing conversions so they can be avoided.
In addition to disallowing implicit narrowing conversions, Option Strict generates an error for late binding. An object is late bound when it is assigned to a variable that is declared to be of type Object.
Because Option Strict On provides strong typing, prevents unintended type conversions with data loss, disallows late binding, and improves performance, its use is strongly recommended.
In other words, Option Strict restricts implicit data type conversions to only widening conversions. Widening conversions explicitly do not permit any data type conversions in which data loss may occur and any conversion between numeric types and strings.
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Given an array of byte, what's the best way to convert it to something like an array of signed short (taking two bytes per value)? In C, it's possible to do something like "*shortptr = (short)(ptr[0] + (ptr[1] << 8));" and have the compiler silently handle the fold-over of 32768..65535 to -32768..-1; no muss no fuss. Is there any practical alternative to something like "shortvar = bytes[i] + ((bytes[i+1] and 127)-(bytes[i+1] and 128))*256"? That extra masking step seems excessively clunky.
|
|
|
|
|
Don't ask a completely unrelated question as a reply to a thread that someone else created. Start a new thread.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|