Immediate Window

MadeCurler

enthusiastic pensioner
Local time
Today, 02:33
Joined
Dec 6, 2007
Messages
49
I'm very new to VBA and don't want to look an idiot in the open forum but I'm studying alone from books and for "fun" and it sometimes gets very frustrating when I can't find it on the web. I'm covering "debugging" at the moment and looking at how to use the "immediate" window. I understand how to use it to test "functions" by passing approriate arguments but how do I test this "Select Case" sub?

Sub UpdateRegionName(pForm As Object)

Select Case pForm.[RegionNumber]
Case "1"
pForm.[RegionName] = "Aberdeenshire Morayshire and Royal Deeside"

Case "2"
pForm.[RegionName] = "Ayrshire South West Scotland and Scottish Borders"

Case "3"
pForm.[RegionName] = "Inverness-shire and Cairngorms National Park"

Case "4"
pForm.[RegionName] = "Loch Lomond Glasgow Edinburgh and the Lothians"

Case "5"
pForm.[RegionName] = "Lochaber Western Highlands Argyll and Bute"

Case "6"
pForm.[RegionName] = "Perthshire Stirlingshire Angus and Fife"

Case "7"
pForm.[RegionName] = "Scottish Islands"

Case "8"
pForm.[RegionName] = "Sutherland Caithness and Ross-shire"
End Select
Debug.Print pForm; [RegionName]

End Sub
 
I find it useful when debugging VBA to set a breakpoint by clicking on the left hand margin. The code will stop when it gets there. You can then go through the code one line at a time by pressing F8. if you hover the cursor over a variable it will display the current value.
 

Users who are viewing this thread

Back
Top Bottom