-
Jul 22nd, 2018, 08:50 PM
#1
Thread Starter
Hyperactive Member
equivalent of vb6 .bas file for c#, c++, visual basic .net?
I am coming from vb6 and wondering what would be the equal to a vb6 .bas file in each of these languages?
visual basic .net
c#
c++
and do they basically work the same way?
-
Jul 22nd, 2018, 09:13 PM
#2
Re: equivalent of vb6 .bas file for c#, c++, visual basic .net?
This is not really a question you need to ask. In VS, you add items of the types you need to your project and it will create a file or files of the appropriate type.
Code files for VB.NET, C# and C++ will have extensions of ".vb", ".cs" and ".cpp" respectively and that is what you'll get if you select the Code File item template. Using VB as an example, you'll also get ".vb" code files if you select various other item templates, including any item in the Code category. If you right-click your VB project in the Solution Explorer and select 'Add' -> 'New Item' and then select an item template from the Common Items category, you'll see the proposed file name at the bottom of the dialogue and you'll see that it has a ".vb" extension in most cases, but there are other file types for some item templates.
Keeping in mind that I have never actually used VB6, I think one point to note is that it has ".frm" files for forms and ".bas" files for code while VB.NET doesn't have a dedicated file type for forms. The designer code and the user code for forms are both in ".vb" files but you will also get a ".resx" file, which is what .NET uses in various places for storing resources using XML.
Last edited by jmcilhinney; Jul 22nd, 2018 at 09:17 PM.
-
Jul 22nd, 2018, 09:42 PM
#3
Thread Starter
Hyperactive Member
Re: equivalent of vb6 .bas file for c#, c++, visual basic .net?
Thanks, ok I will have to experiment with these. I have some old vb6 .bas files, hoping to reconstruct some old api/subs/functions into new .net code..
-
Jul 22nd, 2018, 09:50 PM
#4
Re: equivalent of vb6 .bas file for c#, c++, visual basic .net?
If you want to create a code file with API declarations in it then the most common convention in VB.NET would be to create a module or a class with Shared methods and name it NativeMethods. As I said earlier, both the Module and Class item templates will generate a ".vb" file. You can then call those methods in your code as, for instance, NativeMethods.FindWindow and NativeMethods.FindWindowEx. If you use a module rather than a class then qualifying the method name with the type name is optional. It's up to you whether you use the name 'NativeMethods' but I would definitely recommend one or more types (modules or classes) dedicated to those API declarations. You might, for instance, have a NativeMethods namespace in your project and then have separate types for each unmanaged DLL, e.g. a User32 class containing FindWindow and FindWindowEx methods in the MyProject.NativeMethods namespace.
-
Jul 23rd, 2018, 05:47 AM
#5
Re: equivalent of vb6 .bas file for c#, c++, visual basic .net?
jmc covered the details. The bottom line, pretty much, is that a .bas file in VB6 is a Module so has global visibilty and would be essentially the same as selecting the Module template in VB.net. The nearest thing in C# and C++ would be a static class. The file ending does not indicate the global, static nature of the class (or module in VB's case) in C#, C++ or VB.Net. It is the content of the file that determines what scope and mechanics the object possesses.
-
Jul 23rd, 2018, 06:03 AM
#6
Re: equivalent of vb6 .bas file for c#, c++, visual basic .net?
For future reference, instead of asking a question like the one you did, I would suggest actually explaining what you're trying to achieve. Don't assume that there will ever be a 1:1 correspondence between languages and also don't assume that people who could actually help you achieve your aim have any idea what a BAS file does in VB6.
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
|