![]() |
|
|
FlashChat | Actuarial Discussion | Preliminary Exams | CAS/SOA Exams | Cyberchat | Around the World | Suggestions |
|
View Poll Results: What is the best way to learn VBA? | |||
Book |
![]() ![]() ![]() ![]() |
109 | 35.62% |
Help |
![]() ![]() ![]() ![]() |
48 | 15.69% |
Internet |
![]() ![]() ![]() ![]() |
154 | 50.33% |
Macro Recorder |
![]() ![]() ![]() ![]() |
117 | 38.24% |
Multiple Choice Poll. Voters: 306. You may not vote on this poll |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#31
|
||||
|
||||
![]() VBA help sucks, unless you already knew the answer and just forgot.
Example You want to learn the For...Next syntax. You're a newbie. You go to Language reference, find "For" and their example is like: ' This example sets the Windows OLE RIMM socket to the DLL speed of the unihex DIP switch relayed by the socket connection of the LPT1 (LPT2) port (CPT[open_com] in Windows XP SP 1). DIM windows_cgi_bin_interface_comlink as Integer #DEFINE comlinks.count Application.OLEboundControls FOR windows_cgi_bin_interface_comlink = comlinks.count TO LPT1.open_port.DLLlinks(,,OLE) Debug.Print windows_cgi_bin_interface_comlink Application.parent.ports.&opencom speed:=8008 hex2uni(OLE_bound) Mod 16 'For Windows XP SP 1 please consult user manual NEXT windows_cgi_bin_interface_comlink As Seinfeld says, good luck with all that. |
#33
|
||||
|
||||
![]() Quote:
For...Next Statement Example This example uses the For...Next statement to create a string that contains 10 instances of the numbers 0 through 9, each string separated from the other by a single space. The outer loop uses a loop counter variable that is decremented each time through the loop. Code:
Dim Words, Chars, MyString For Words = 10 To 1 Step -1 ' Set up 10 repetitions. For Chars = 0 To 9 ' Set up 10 repetitions. MyString = MyString & Chars ' Append number to string. Next Chars ' Increment counter MyString = MyString & " " ' Append a space. Next Words |
#34
|
||||
|
||||
![]() A useful example would be this:
DIM i as integer FOR i = 1 TO 15 STEP 3 Debug.print i NEXT i will output as follows: 1 4 7 10 13 Done. Now I know how to use FOR. I'll figure out how to nest two of them or use string concatenation on my own. Or better yet, by going to help on "&", which should have an example like "straw" & "berry" ' equals "strawberry" but in VBA help probably just refers you back to this same FOR..NEXT example. Last edited by Phil; 08-10-2006 at 01:55 PM.. |
#35
|
||||
|
||||
![]() Quote:
|
#36
|
||||
|
||||
![]() Quote:
1. Crap code - sometimes from the recorder, sometimes from the bliss of ignorance of the coder. 2. Often, no variable declarations - again, due to total ignorance on the part of the coder. 3. Sloppy or nonexistent documentation of the code, leaving a mass of spaghetti for the poor slob that inherits that code. Brad
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: Last edited by Brad Gile; 08-10-2006 at 06:38 PM.. Reason: tone things down a tad. |
#37
|
||||
|
||||
![]() Quote:
__________________
I've never heard of such a brutal and shocking injustice that I cared so little about. |
#38
|
||||
|
||||
![]() Quote:
Many of these are not trying to learn VBA, just generate code that works. The question isn't is the VBA recorder a bad way to generate code (which it is), but is it useful in learning how to program (which it is). |
#39
|
||||
|
||||
![]() Quote:
Moreover, I agree with Bama that the recorder is highly limited as an educational tool. It is most useful for those who already have good programming techniques. But, whatever. ![]() Brad
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: |
#40
|
||||
|
||||
![]() "What's the best way to learn programming?" <> "What's the best way to learn VBA?"
__________________
I've never heard of such a brutal and shocking injustice that I cared so little about. |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|