-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
Oct?
Convert.ToString(New Integer, 8)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Quote:
Originally Posted by eyeRmonkey
Technically that is true, but you have to agree that an OO approach is better than being stuck to your old VB6 habbits.
I don't like using Runtime functions if there is a better alternative but this is not a valid argument. VB.NET is a 100% OO language. It is not possible to do anything in VB.NET that is not OO. Using a Runtime function is no different to using a Shared member of a class.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
There is no possible replacement for IIf in VB.NET except a full If...Then...Else...End If block.
I don't know how SendKeys works in VB6 but I'd assume that the SendKeys class provides the equivalent functionality and probably more.
Quote:
Originally Posted by penagate
SendKeys = Application.SendKeys
I think you just made that up. :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
Yes, it looks very much as though I did. :blush:
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Quote:
Originally Posted by jmcilhinney
I don't like using Runtime functions if there is a better alternative but this is not a valid argument. VB.NET is a 100% OO language. It is not possible to do anything in VB.NET that is not OO. Using a Runtime function is no different to using a Shared member of a class.
I knew someone would dispute me on that one. I don't know how to phrase it so it is "technically correct," but I think you know what I mean. Why use VB6 functions (even though they are now part of the .NET framework) when there is a .NET approach.
Yeah, I figured out what you meant Penagate. ;) SendKeys.Send() functions does the job. :)
Thanks everyone. I will be posting a new version in a few minutes.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
I absolutely hate using SendKeys in either VB6 or VB.NET. It should have never been invented. The most flakey of all methods of all time! :D
Use unmanaged code (APIs) to do it reliably. :thumb:
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available
Quote:
Originally Posted by RobDog888
I absolutely hate using SendKeys in either VB6 or VB.NET. It should have never been invented. The most flakey of all methods of all time! :D
Use unmanaged code (APIs) to do it reliably. :thumb:
I'm with you Rob. Given that SendKeys acts on the control that currently has focus and that there is no way to guarantee what the active control is at any time, the result of SendKeys cannot be predicted with an acceptable level of certainty.
I don't use Runtime functions if I can avoid it for the following reasons:
1. They are often (although not always) less efficient than System-based alternatives.
2. They often call the very members that you would normally use to replace them (e.g. MsgBox and MessageBox.Show) so why add the extra layer? This is also a contributor to reason 1.
3. Their behaviour is sometimes what I would consider idiosyncratic, e.g. Val().
4. They are often abominably named. Who would know what Fix() does without looking it up? The naming conventions in the .NET Framework make a lot of code self-documenting.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
Sorry EM, but this guy has done what your doing but for VB6 > VB.NET & C#. Good stuff too. :)
http://www.codeproject.com/dotnet/vb...difference.asp
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
Quote:
Originally Posted by RobDog888
I don't see the VB6 part :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
:blush: neither do I :lol:
Nevermind, but it is a helpful link for VB to C# :D
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available
Quote:
Originally Posted by RobDog888
:blush: neither do I :lol:
Nevermind, but it is a helpful link for VB to C# :D
Thanks for the helpful vb to c# link then RD :wave: :p
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Good link anyway RD. Thanks.
Okay, the updated (and hopefully near final) version is posted. Enjoy. :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
I read your final list and I want to point out that CStr, CInt, etc. are NOT members of the Microsoft.Visualbasic namespace. Notice that they turn blue in the IDE, indicating that they are VB.NET keywords. They are part of the VB.NET language itself, so I for one certainly do not equate their use with the use of Runtime functions.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Hmmm. I didn't know that. So what are they then? Okay, I know I started a thread on this subject already and I know it goes back to casting and what not. Is that the reason they exist in two similar forms? One for casting and one for doing it the other way?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
CInt, CStr, etc. existed in VB6 and earlier and behaved a certain way. I believe they still behave that same way, but they are VB.NET keywords and are compiled inline rather than creating a function call. Their functionality includes some of what C-style casting provides, which didn't exist in VB6, and some of what the Convert class and similar things provide, although they do not necessarily work the same way. This is the reason I like to use them for casting and Convert or the like for actually converting objects. That is a matter of personal preference but I believe that it helps to keep things more consistent, particularly if you also use C# where you will use a genuine cast where appropriate and a conversion otherwise.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Well, I still don't understand the whole concept of casting, but that isn't the topic of this thread, so I will remove them from the list because they are all fairly obvious and because you have a point. Thanks. :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
If you guys wouldn't mind, I think it would be helpful to link to either this thread or the table in your signatures. I think it will solve a lot of simple problems that people run into when switching from VB6 to .NET. Thanks. :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
I've noticed some erros in the section including FormatDateTime and the like. If you want to use the String.Format method then you do NOT call it on a String object because it is a Shared method. The old Format function is replaced by String.Format where you call it on the class, not an instance. As for the others, you could use String.Format but it would be more correct to do as follows:
FormatCurrency => myNumber.ToString("c")
FormatDateTime => myDate.ToLongDateString, .ToShortDateString, .ToLongTimeString, .ToShortDateString, .ToString(formatString)
FormatNumber => myNumber.ToString(formatString)
FormatPercent => myNumber.ToString("p")
Take a look at these links to see what sort of values formatString can take.
Standard DateTime Formats
Standard Number Formats
Custom Number Formats
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by eyeRmonkey
If you guys wouldn't mind, I think it would be helpful to link to either this thread or the table in your signatures. I think it will solve a lot of simple problems that people run into when switching from VB6 to .NET. Thanks. :)
I must insist that you fix the appalling Word-generated HTML code! :eek:
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by penagate
I must insist that you fix the appalling Word-generated HTML code! :eek:
Shhhhhhhhh!
I was feeling lazy. I moved it to appalling FrontPage-generated HTML code. ;)
JMC, could you explain how/when/why I would call format on a class? I'm not sure I follow you on that one.
EDIT: I updated the page. Does it look more correct JMC?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by eyeRmonkey
JMC, could you explain how/when/why I would call format on a class? I'm not sure I follow you on that one.
If you have a single object that you want to convert to a string and specify a format then you would normally call the ToString method of that object. If you want to insert an object into a string at a specific point or you have multiple object s that you want to put into a string then you would normally use String.Format. String.Format allows you to specify the same format strings that you can pass to ToString.
Quote:
Originally Posted by eyeRmonkey
I updated the page. Does it look more correct JMC?
There's still an error with Format. String.Format is a Shared method so you don't call it on a String object, but rather on the String class itself, i.e.
Format => [String object].Format 'this is wrong.
Format => String.Format 'this is correct.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Nevermind. I understand now. That totally makes sense. I knew that, I just wasn't making the connection for some reason. Thanks. :)
(If I could rep you as much as you deserved it, my finger would be bruised. ;))
EDIT: I know this sounds ridiculous, but would the proper way to acheive the VB6 equivalent of Format be to do [String Object].ToString([Format String Here])? Or is there a way that seems less... odd? String.Format() doesn't do the same thing as in .NET as it did in VB6, so I can't list it as the equivalent.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by eyeRmonkey
EDIT: I know this sounds ridiculous, but would the proper way to acheive the VB6 equivalent of Format be to do [String Object].ToString([Format String Here])? Or is there a way that seems less... odd? String.Format() doesn't do the same thing as in .NET as it did in VB6, so I can't list it as the equivalent.
I hadn't previously looked to see what the Format function did. It just seems to be a more generalised version of FormatCurrency, FormatDateTime, etc., so the equivalent would be something like [Object].ToString([Format String Here]) because it's a date or number that you're converting to a string.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Yeah, that makes sense. I was thinking I needed to specify exactly what the [Object] was, but keeping it generalized works fine. I'll upload the new version now.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by eyeRmonkey
Shhhhhhhhh!
I was feeling lazy. I moved it to appalling FrontPage-generated HTML code. ;)
OK.
Take 3 steps back.
Now put the FrontPage down. Slowly.
http://penagate.spiralmindsinc.com/misc/functions.html
(You might need to update the content slightly ;))
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
*bursts into tears*
... It's so ... Beautiful. :p
I was actually going to ask if someone would be willing to make it look nice for me. Did you hand code that? Or did you use an editor? It looks awesome. I wish I could rep you right now. Thanks!
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
No problemo :)
Hand code ;) I use Notepad++.
Move the CSS to a stylesheet if you want to save some more bandwidth, along with the savings from lack of Frontpage/Word muck :p
Edit: Mighta missed a few "deprecated"'s somewhere
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Penagte, I must say, you are an artist at heart. You have a gift for that kind of thing. I can code with the best of them, but I'm not much of a designer. I'm not horrible, but I am far form amazing.
Good work, I'll check out stuff and make sure it is all up to date.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
I just noted that you have not provided a replacement for Oct. You can use Convert.ToString([Integer], 8) to create an octal representation of a number and Convert.ToInt32([String], 8) to create a number from an octal string. The same thing works with bases 2, 10 and 16.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Yeah, I had it updated at some point, and it got lost between updates or something. Thanks. :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by eyeRmonkey
Yeah, I had it updated at some point, and it got lost between updates or something. Thanks. :)
Ah, i looked a penagate's version I think. It's his fault. :)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
:lol:
The link in the first post now leads to the updated version with Penagate's design.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
What on earth happened to my poor code layout :lol:
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Int() is equivalent to Math.Floor(). Fix() is NOT equivalent to Math.Floor(). Fix behaves like Math.Floor for positive numbers and Math.Ceiling for negative numbers. The closest thing to Fix is Decimal.Truncate, but that only acts on Decimals, not Doubles or Singles.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Thanks agian. I didn't think that was right, but I didn't know exactly what Fix did, so I just put Math.Floor there. Fix sounds like the greatest integer function (from math).
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Quote:
Originally Posted by penagate
What on earth happened to my poor code layout :lol:
:bigyello:
It is still just the way you left it. :p
I even kept your random use of capitalization and what not. Hehe.
Looks great Penagate. Thanks again. :thumb:
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Eh... my source code is completely different... :confused:
Somehow your version manages to have the same effect, but with added, as you say, random capitalisation and what not.
In case your View Source function is malfunctioning, here's the original code :p
http://penagate.spiralmindsinc.com/misc/functions.htmls
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
:sigh: Somehow the way I saved it screwed it up. The actual code looks perfect (as proper XHTML should - even though you have HTML 4.01 as your doc type). Anyway, I don't really want to make all the changes again just so the source looks nice, but I might if it isn't too much trouble.
Also, I changed the URL, so if anyone bookmarked it or something you will need to change it. Sorry for any trouble that causes, but I wanted to make it easy to remember and an ASP page so I could add other functionality later.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]
Thanks for all your work, have added it to my favourites as am always getting confused with Vb6 and .net.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Final Draft]