Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to learn Visual Basic
Message
 
To
12/06/2001 08:49:03
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00518307
Message ID:
00518370
Views:
16
Hi Randy,

Learning VB is fun <g>. Here's a couple tips and pointers I've found.

First, download the following freeware utils.

mzTools, this is an add-in to vb that is a must have. To many features to list here but it allows you to setup standard error handling and procdure and module headers, in-project task list, GUI to build new procdures and property let/get/set, etc...
http://www.mztools.com/

Beatify for VB, another can't live without this.
http://www.bmsltd.co.uk/Indenter/IndentPage.asp

Here's the link to les' vfp->vb concordance. List all vfp commands and thier vb counterparts. some are missing but it certainly helps.
http://www.lespinter.com/Articles/English/216.htm

Tips:


  1. Creating an object: this one made me nuts for awhile. You set vars the same as you do in vfp:
    dim x as string
    x = "SomeString"
    but with object you always have to use the set function
    dim MyForm as Form
    set MyForm = new form
    MyForm.Caption = "SomeString"
  2. Property Let/Get/Set: These work like access and assign in VFP. There difference between Let and Set is Set is for a property with an object for the parameter, see item 1 above.
  3. VB Setup: In the Tools->Options menu do the following:
    Go to the docking page and undoc everything.
    On the General page un-check "Auto Syntax check". That thing will make you nutty. It pops up a dialog every time you make a syntax error.
  4. If..Then..ElseIf...Else. Then, Then, Then. You will forget. You always have to put the then after the test.
    If x = y <b>Then </b>
       x + 1
    ElseIf x <> y <b>then</b>
       x + 2
    Else
       x - 1
    Endif
  5. There is no ? in vb you use debug.print instead. Exception, in the immediate pane you can use ? and it will convert it debug.print for you.
  6. Turn Option Explicit on: This forces you to declare your vars.
  7. Learn how to use enums.
    enums let you set a group of named contants. Very cool
    Public Enum MyDays
       myMonday = 1
       myTuesday = 2
       myWednesday = 3
    end Enum
    
    dim WhichDay as myDays
    WhichDay = myMonday
    Plus they display the named value with intillisense
  8. UDT's rock. A UDT is a User Data Type. I think of them as simple objects. It's really just a memory var that you can give names.
    Public Type myPerson
       birthDate As Date
       lastName As String
       firstName As String
       address As String
    End Type
    
    Dim OldGuy as myPerson
    with OldGuy
       .birthdate = #03/03/1864#
       .firstName = "Old"
       .lastName = "Geezer"
       .address = "Cemetary"
    end with
    Why do they rock you ask? In a biz object class you define a UDT that holds the values for all the props of an object. Then use property let/get/set to provide public access to the biz object props. Now you can save a copy of the udt using lset and restore it with a cancelEdit function. See the Vb Business object book I mention later for a way to do this.


I've read a bunch of the wrox vb books and they are pretty good. Rockford Lhotka < sp? > vb business objects is pretty good. He has some great ideas for building fully data-centric object oriented applications. Also look at the COM book by wrox, forget the name, liked that one.

That's all I can think of right now. Let me know if you have questions. Or post in the vb forum.


>I am fairly good with VFP6. I want to learn Visual Basic now. I have Murach's Visual Basic book, but there is so much that I already know because of my knowledge of VFP6.
>
>My question: is there a book/article that compares the two, in detail?
>
>Thanks,
>Randy
>
>This msg also posted on the VB forum.
Roi
'MCP' Visual FoxPro

In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!
Previous
Reply
Map
View

Click here to load this message in the networking platform