Hi Rick,
I am moving from VFP to VB .NET but after looking around a bit on the internet it seems to me (correct me if I'm wrong) as if some of the things to which I have become accustomed using VFP will be much more difficult using VB .NET.
For example I don't think VB .NET has anything native that is the equivalent of either of the VFP functions OCCURS() or STREXTRACT(), both of which I have found invaluable over the years.
I have also seen comments on Foxite and in other places that say that VFP Cursors are not easily replicable in VB .NET.
I suspect that I am in for a bit of a shock departing from VFP's strong string manipulation and SQL environment.
Do you have any general or specific advice as far as the move from VFP to VB .NET goes?
Any advice would be greatly appreciated.
Regards,
Russell.
I'm sure that people with more knowledge and experience than myself will answer this question, but my first suggestion is NOT to use VB.NET and use C# instead.
Sure, VB.NET sounds like it should be simple to learn because it's 'VB'. In my opinion, VB.NET is not like good old VB to make it worth using. There is still a huge learning curve.
The reality is that MOST .NET developers are using C#. Most examples that you get when you Google up a problem for help will be in C#. There's also the StackOverflow site instead of Google and again 95% of the example code is in C#.
Don't be afraid of C# because it's really not like C or C++. It's actually quite easy to learn.
As far as the familiar string or any other type FoxPro functions that you are used to using there's a lot of built-in stuff in the .NET Framework. There is, however, a VFP .NET library somewhere that allows you to use VFP like functions. This library is written in C#.
Good luck!
Here is the library that adapts some functions of VFP to .NET.
Thanks a lot for your feedback Jeff and for the link Arcadio!
You can find a ton of helper functions in my free Westwind.Utilities
library.
There's StringUtils.Extract() for STREXTRACT()
and many other string related helpers.
For data access there's the SqlDataAccess()
class which makes getting SQL data very easy - single line commands for the most part. If you want VFP like cursors you can use data.ExecuteDataTable() which gives you a dynamic DataTable that's cached in memory or a number of other method that can pull data into predefined or dynamic objects.
FWIW I agree strongly with Jeff in that you're better off using C# than VB.NET as almost all .NET examples are given in C# code so it's easier to work with, especially if you are learning. The last thing you want to do is convert sample or StackOverflow solutions from C# to VB all the time.
+++ Rick ---
+++ Rick ---
Thanks so much Rick. That all sounds very promising.
Hi again Rick.
I think I have managed to install that package into Visual Studio but I have been trying to find documentation on your classes and have come up short.
Would you be able to point me in the right direction for a list of your functions, their syntax, examples of usage etc. please?
Thanks in advance.
Russell.
Hmmm... yes the docs are are an issue with this as this library was recently moved onto its own out of the West Wind Toolkit and the docs didn't migrate. You're actually giving me a kick in the butt to create a new seperate set of docs for just the Westwind.Utilities
library.
Update
I've pushed up new documentation at https://docs.west-wind.com/westwind.utilities/ which holds the latest documentation for these classes.
Here are a few topics that relate to this discussion:
Note the DataAccessBase
class is the base class for SqlDataAccess
and so provide most of the functionality that's available for data access.
+++ Rick ---
Ok I've pushed up a current set of documentation for West Wind Utilities here:
I've updated the link in the previous message to point at the new docs.
+++ Rick ---
Thank you very much Rick. Didn't mean to kick you up the butt!!
Very nice Rick. There is lots of stuff in there!
You are no doubt already aware but if not there is also the VFPToolkit for VB.NET, which is a nice package.
http://foxcentral.net/microsoft/vfptoolkitnet.htm
Update: Woops. Forgot that Arcadio already mentioned that package above!! D'Oh.
The problem with the VFP Toolkit is that it uses a lot of FoxPro conventions rather than using proper .NET conventions, so generally I don't recommend going that route to avoid getting into bad habits. The code can be useful and the source is available so if there things you need it's easy to wrap them up with proper .NET interfaces that are more inline what you'd expect in .NET.
+++ Rick ---
Thanks Rick.
As someone new to VB .NET the temptation for any easy transition by using the VFPToolkit is great but I understand what you're saying.
Rick,
Out of curiosity, what would be the difference in using the VFP toolkit or its functions in Westwind.Utilities? In both cases, would not you be using facilitators? What would be the differences in your opinion?
Functionality wise probably not much. Language wise a lot of those functions have odd names and formatting and parameter conventions. Like I said it works and it's fine to use, just don't use it as a guideline to build your own functions. Frankly - if you're starting out it's a great exercise to rebuild those functions in your own library (even if you cheat and just copy their code).
Pragmatism would suggest that it all doesn't matter, but as somebody who started out originally doing .NET with a FoxPro focus and using Fox conventions for even just a short while, it's a bad habit and one you'll regret as you go on. So it's better to build stuff using proper .NET conventions even if they are a little different than what you're used to. They will feel natural soon enough.
+++ Rick ---
Hi Rick,
I ended up connecting to a local VFP table in Visual Studio (using VB.NET) as per the screen dump below.
I was wondering whether I have any direct control over the speed of the SQL query doing it via OLE DB as I did with VFP (ie. with indexes / Rushmore)?
Regards,
Russell.