-
Please Help Create A VB6 to .NET Function Conversion Chart [Completed]
Visual Basic 6 to .NET Function Equivalents (Updated 3/19/2006)
EDIT: Moved the page to my wiki. Now anyone can edit it as they see fit.
While learning .NET, I realized that the main obstacle was finding out what the .NET equivalent was to every VB 6 function. I have created this chart to help people in my situation. Follow the link above to see the chart. Email me at the link provided there, or post here to give feedback or to tell me about errors.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
There are only a few left compared to original list. I would be very thankful for any and all help.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I know the rest but i'm going to bed now, 2am lol. During the day tomorrow I will complete it and post it.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Quote:
Originally Posted by eyeRmonkey
There are only a few left compared to original list. I would be very thankful for any and all help.
Which are left?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Quote:
Originally Posted by Vektor
I know the rest but i'm going to bed now, 2am lol. During the day tomorrow I will complete it and post it.
Thanks. I would really appriciate that.
Wild Bill, the list in the main post is all that is left. The original list was a lot longer though. I made that comment because I thought the reason no one was replying was because they saw how long the original list was.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Shell - Process.Start
MsgBox - MessageBox.Show
Randomize - Random Class
SavePicture - Image.Save BitMap.Save, etc
Of course, I dont really have much VB6 knowledge, just thought I would throw those in since I had nothing better to do...
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I actually had Shell and MsgBox already and forgot to remove them.
Randomize doesn't exist in the Random class as far as I can tell. Is it even necessary? Or can you just call [System.Random Obejct].Next without the Randomize .NET equivelant (if it exists)?
Thanks for SavePicture.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Randomize shouldnt be necessary at all if you use the random class, and Random.Next...
Refer to this thread when I got in trouble for suggesting it :p
http://www.vbforums.com/showthread.php?t=363148
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Cool. I will list it as depricated.
I was trying to figure out how to find a simple of to accomplish StrReverse in .NET and the best thing that I can come up with is way to long and looks like this:
VB Code:
Dim MyString As String = "test"
Dim MyArray As System.Array
MyArray = MyString.ToCharArray
Array.Reverse(MyArray)
MyString = Convert.ToString(MyArray)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
You can simply loop the chars of the string, and just append it to the front of the result string, like below:
VB Code:
Dim MyString As String = "ReverseMe"
Dim ReverseString As String = ""
For Each Letter As Char In MyString
ReverseString = Letter & ReverseString
Next
MessageBox.Show(ReverseString)
Its the same code length (since you didnt put a messagebox displaying the variable above), but doesn't require converting them to an array, or temp array, etc...
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I was trying to put this all in a spreadsheet and I don't want to put 5 lines of code. I suppose I could just put "use a loop" or something.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
hehe well Im not sure if there is a shorter way without using the runtime function, you can always do this if needed:
VB Code:
For Each Letter As Char In MyString : ReverseString = Letter & ReverseString : Next
That enables you to put everything in one line in the IDE (seperating them with a colon), and gives you one line to put in your spreadsheet....
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
How about these: ChDir, ChDrive, CurDir. Directories don't even work that way in .NET do they? In VB6 your kind of had a directory that it was "focused" on and whenever you did any directory actions, it would automatically happen to that directory. In .NET you need have the whole directory class. Any idea how to convert those?
Oh, I just found these one:
CurDir = [IO.Directory Object].GetCurrentDirectory
ChDir = [IO.Directory Object].SetCurrentDirectory
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Heres DIR Folders
VB Code:
For Each Dir As String In IO.Directory.GetDirectories("C:\")
Debug.Print(Dir)
Next
Heres DIR Files
VB Code:
For Each Dir As String In IO.Directory.GetFiles("C:\")
Debug.Print(Dir)
Next
File Exists
VB Code:
If IO.File.Exists("C:\a.bat") = True Then
Debug.Print("True")
End If
Len = String.Length
Easy Read/Write
VB Code:
My.Computer.FileSystem.ReadAllText("C:\a.txt")
My.Computer.FileSystem.WriteAllText("C:\a.txt", "Today", False)
About all I got that could interest you
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Thanks Remix!
How about Len when used with data types? It tells you the number of bytes that object/type takes up.
My keyword is only in .NET 2005. I would like to keep this more universal. I like the ability to read/write a file in one line though! Is there anyway to do it in one line in other versions of .NET.
Anyone have any idea how to do Hex or Oct (or Binary even though it didn't exist in VB6) using .NET? I get the feeling they might not exist anymore.
Also, what is the difference between Fix and Int in VB6? And what is the best way to do that in .NET? All I could come up with is Convert.ToInt32 or Math.Round.
Does InputBox exist anymore?
PS - It is Debug.Write or Debug.WriteLine. Debug.Print was so two years ago! :wave:
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Windows.Forms.Application.DoEvents() 'DoEvents
Convert.ToChar(26) 'EOF
Int32.ToString("x") 'Hex
String.Join("", s()) 'Join
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Thanks Wild Bill. The only one that doesn't work is EOF. In VB6 EOF returned a boolean value telling you if a specified file had reach the end of the file or not. I know VB .NETs setup for files is totally different, but can we find something similar?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I think I will just list EOF as "[StreamReader Object].Peek = -1"
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Try,
VB Code:
Debug.Print(Int16.MaxValue.ToString)
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
something like this might work
VB Code:
Const EOF As String = Nothing
Dim sr As New IO.StreamReader("c:\temp\test.txt")
Dim line As String = sr.ReadLine
While line <> EOF
line = sr.ReadLine
End While
sr.Close()
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Quote:
Originally Posted by |2eM!x
Try,
VB Code:
Debug.Print(Int16.MaxValue.ToString)
Len told you how many bytes something was. Plus its main use was for Objects that you created yourself. For example, if you made your own class and had an instance of it, you could figure out how many bytes the structure took up. Should I list it as depricated?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
No idea..Never used/needed it, sorry.
edit* cant you get the number I gave you, /2 and get the bytes?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
You can, but that only applies to objects/data types that have a MaxValue property.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
The equivelent of Len is Marshal.SizeOf() I believe. Atleast in some cases. That is what I have replaced Len with when woking with APIs.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Yeah, I totally told you so.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Environ is now Environment
Reflection replaces CallByName According to this
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I don't really know how CallByName worked in VB6, but can you point mew towards to a specific part of the Reflection class?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Here's an example
VB Code:
Dim t As Type = GetType (TestClass)
' BindingFlags has three bitor'ed elements. Default indicates that
' default binding rules should be applied.
t.InvokeMember ("SayHello", _
BindingFlags.Default BitOr BindingFlags.InvokeMethod _
BitOr BindingFlags.Static, nothing, _
nothing, new object () {})
This calls a method named SayHello.
You have to import system.Reflection then Call InvokeMethod on a type.
I got the example from here.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
So would It be fair to list CallByName like this?
[Type Object].InvokeMember
I plan to link each line of the chart to a good example or page on MSDN so I think that will be enough info. Do you agree?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I think that might be the only way to show it nicely, and complete.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
(I just edited it. Do you still agree that is the best way to post it? As long as I link it to and example.)
That only leaves Oct. I did Hex like this: [Integer Object].ToString("x") but I don't know how to do that with Oct.
Also I need to find a good way of listing all the depricated functions. I want to put a comment next to every depricated function that at least gives some info about it or points the user in a good direction if that is what they are looking for.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Current way is better. Maybe have an astrics with a note at the bottom that says may require importing a namespace. Check MSDN for requirements? Something tlike that? Because another one that requires an imports statement is marshal.SizeOf.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Oddly, neither of those require a reference for me. The following work without references:
VB Code:
Runtime.InteropServices.Marshal.SizeOf
' AND ...
Dim t as Type = GetType(MyType)
t.InvokeMember
Well they don't WORK, but they pop up form Intellisense. I havn't actually tried either of them though. I only have the default imports set up.
Everything will be linked to MSDN so that should suffice for this one.
Does anyone have any ideas for Oct or for the ones I have listed as depricated? Like I said, I want to put a note next to each depricated one that gives the user an idea of where to head. For example, next to Err I put "(Depricated - Use Try ... Catch ... Finally statement and Exception object instead)." I need help finding things like that for all the depricated functions.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Here is a rough draft. Almost everything is linked to MSDN. I would really appriciate it if everyone could skim over it and make sure everything is valid.
EDIT: I moved the link to the first post.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
What Depricated means? :confused:
About StrReverse, why to loop in .Net if it still works as in VB6?
Or you don't want nothing from Microsoft.VisualBasic?
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Deprecated ;)
SendKeys = Application.SendKeys
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Quote:
Originally Posted by jcis
What Depricated means? :confused:
About StrReverse, why to loop in .Net if it still works as in VB6?
Or you don't want nothing from Microsoft.VisualBasic?
Deprecated (as Penagate pointed out) means out of date and obselete.
As far as StrReverse, the whole point of this table is to help people avoid using the Microsoft.VisualBasic namespace. The idea is to help people get out of their old "VB 6 habbits" and into a more object oreiented approach.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
There's nothing wrong with the Microsoft.VisualBasic namespace.
:p
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Technically that is true, but you have to agree that an OO approach is better than being stuck to your old VB6 habbits.
-
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Rouch Draft Available]
Okay, the most recent version is linked in the first post. If no one else has any comments I will polish it up and give you guys the final link. Hopefully a few people will be willing to link to it in their signatures and we can help people stop using the Microsoft.VisualBasic namespace.