-
Mar 15th, 2006, 07:33 PM
#1
Thread Starter
No place like 127.0.0.1
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.
Last edited by eyeRmonkey; Mar 9th, 2007 at 12:03 AM.
Reason: changed URL
-
Mar 16th, 2006, 10:04 AM
#2
Thread Starter
No place like 127.0.0.1
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.
-
Mar 16th, 2006, 12:47 PM
#3
Registered User
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.
-
Mar 16th, 2006, 12:49 PM
#4
Re: Please Help Create A VB6 to .NET Function Conversion Chart
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?
-
Mar 16th, 2006, 08:22 PM
#5
Thread Starter
No place like 127.0.0.1
Re: Please Help Create A VB6 to .NET Function Conversion Chart
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.
-
Mar 16th, 2006, 08:45 PM
#6
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...
-
Mar 16th, 2006, 09:03 PM
#7
Thread Starter
No place like 127.0.0.1
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.
-
Mar 16th, 2006, 09:13 PM
#8
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
http://www.vbforums.com/showthread.php?t=363148
-
Mar 16th, 2006, 09:26 PM
#9
Thread Starter
No place like 127.0.0.1
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)
Last edited by eyeRmonkey; Mar 16th, 2006 at 09:41 PM.
-
Mar 16th, 2006, 09:40 PM
#10
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...
Last edited by gigemboy; Mar 16th, 2006 at 09:43 PM.
-
Mar 16th, 2006, 09:43 PM
#11
Thread Starter
No place like 127.0.0.1
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.
-
Mar 16th, 2006, 09:46 PM
#12
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....
-
Mar 16th, 2006, 09:48 PM
#13
Thread Starter
No place like 127.0.0.1
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
Last edited by eyeRmonkey; Mar 16th, 2006 at 09:51 PM.
-
Mar 16th, 2006, 09:56 PM
#14
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
-
Mar 16th, 2006, 10:16 PM
#15
Thread Starter
No place like 127.0.0.1
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!
Last edited by eyeRmonkey; Mar 16th, 2006 at 10:27 PM.
-
Mar 17th, 2006, 12:46 PM
#16
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
-
Mar 17th, 2006, 03:12 PM
#17
Thread Starter
No place like 127.0.0.1
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?
-
Mar 17th, 2006, 04:09 PM
#18
Thread Starter
No place like 127.0.0.1
Re: Please Help Create A VB6 to .NET Function Conversion Chart
I think I will just list EOF as "[StreamReader Object].Peek = -1"
-
Mar 17th, 2006, 04:29 PM
#19
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Try,
VB Code:
Debug.Print(Int16.MaxValue.ToString)
-
Mar 17th, 2006, 04:33 PM
#20
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()
-
Mar 17th, 2006, 04:45 PM
#21
Thread Starter
No place like 127.0.0.1
Re: Please Help Create A VB6 to .NET Function Conversion Chart
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?
-
Mar 17th, 2006, 04:49 PM
#22
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?
-
Mar 17th, 2006, 04:55 PM
#23
Thread Starter
No place like 127.0.0.1
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.
-
Mar 17th, 2006, 05:02 PM
#24
Frenzied Member
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.
-
Mar 17th, 2006, 05:04 PM
#25
Fanatic Member
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Yeah, I totally told you so.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Mar 17th, 2006, 05:10 PM
#26
Frenzied Member
Re: Please Help Create A VB6 to .NET Function Conversion Chart
Environ is now Environment
Reflection replaces CallByName According to this
-
Mar 17th, 2006, 05:22 PM
#27
Thread Starter
No place like 127.0.0.1
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?
-
Mar 17th, 2006, 05:28 PM
#28
Frenzied Member
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.
-
Mar 17th, 2006, 05:31 PM
#29
Thread Starter
No place like 127.0.0.1
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?
Last edited by eyeRmonkey; Mar 17th, 2006 at 05:43 PM.
-
Mar 17th, 2006, 05:43 PM
#30
Frenzied Member
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.
-
Mar 17th, 2006, 05:48 PM
#31
Thread Starter
No place like 127.0.0.1
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.
-
Mar 17th, 2006, 06:58 PM
#32
Frenzied Member
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.
-
Mar 17th, 2006, 08:23 PM
#33
Thread Starter
No place like 127.0.0.1
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.
Last edited by eyeRmonkey; Mar 17th, 2006 at 08:27 PM.
-
Mar 18th, 2006, 03:21 AM
#34
Thread Starter
No place like 127.0.0.1
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.
Last edited by eyeRmonkey; Mar 18th, 2006 at 01:46 PM.
-
Mar 18th, 2006, 04:25 AM
#35
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
What Depricated means?
About StrReverse, why to loop in .Net if it still works as in VB6?
Or you don't want nothing from Microsoft.VisualBasic?
-
Mar 18th, 2006, 04:56 AM
#36
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Deprecated
SendKeys = Application.SendKeys
-
Mar 18th, 2006, 01:37 PM
#37
Thread Starter
No place like 127.0.0.1
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
Originally Posted by jcis
What Depricated means?
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.
-
Mar 18th, 2006, 01:45 PM
#38
Re: Please Help Create A VB6 to .NET Function Conversion Chart [Almost Done]
There's nothing wrong with the Microsoft.VisualBasic namespace.
-
Mar 18th, 2006, 01:49 PM
#39
Thread Starter
No place like 127.0.0.1
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.
-
Mar 18th, 2006, 10:30 PM
#40
Thread Starter
No place like 127.0.0.1
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|