Resources for Python Programmer [closed] Resources for Python Programmer [closed] vba vba

Resources for Python Programmer [closed]


VBA is quite different from Python, so you should read at least the "Microsoft Visual Basic Help" as provided by the application you are going to use (Excel, Access…).

Generally speaking, VBA has the equivalent of Python modules; they're called "Libraries", and they are not as easy to create as Python modules. I mention them because Libraries will provide you with higher-level types that you can use.

As a start-up nudge, there are two types that can be substituted for list and dict.

list

VBA has the type Collection. It's available by default (it's in the library VBA). So you just do a
dim alist as New Collection
and from then on, you can use its methods/properties:

  • .Add(item) ( list.append(item) ),
  • .Count ( len(list) ),
  • .Item(i) ( list[i] ) and
  • .Remove(i) ( del list[i] ). Very primitive, but it's there.

You can also use the VBA Array type, which like python arrays are lists of same-type items, and unlike python arrays, you need to do ReDim to change their size (i.e. you can't just append and remove items)

dict

To have a dictionary-like object, you should add the Scripting library to your VBA project¹. Afterwards, you can
Dim adict As New Dictionary
and then use its properties/methods:

  • .Add(key, item) ( dict[key] = item ),
  • .Exists(key) ( dict.has_key[key] ),
  • .Items() ( dict.values() ),
  • .Keys() ( dict.keys() ),
    and others which you will find in the Object Browser².

¹ Open VBA editor (Alt+F11). Go to Tools→References, and check the "Microsoft Scripting Runtime" in the list.

² To see the Object Browser, in VBA editor press F2 (or View→Object Browser).


This tutorial isn't 'for python programmers' but I thinkit's a pretty good vba resource:

http://www.vbtutor.net/VBA/vba_tutorial.html

This site goes over a real-world example using lists:

http://www.ozgrid.com/VBA/count-of-list.htm


Probably not exactly what you are looking for but this is a decent VBA site if you have some programming background. It's not a list of this = that but more of a problem/solution

http://www.mvps.org/access/toc.htm