By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,452 Members | 974 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,452 IT Pros & Developers. It's quick & easy.

Wish list vent

P: n/a
This is a vent because it's completely pointless to ask for. After all, VB
Classic is on its way out and I probably won't even be using too much longer
myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was a
WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach

Nov 13 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
rkc

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:m8********************************@4ax.com...
This is a vent because it's completely pointless to ask for. After all, VB Classic is on its way out and I probably won't even be using too much longer myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was a
WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach


For *&#^$%%%!!! sake, why the F*%& not go for

WithEach In Me.Controls.acTextBox
Debug.Print .Name & "=" .Value
End WithEach
Nov 13 '05 #2

P: n/a
So what's wrong with
For each ctl in Me.Controls
?
Of course your code would throw errors in that loop,
because not all controls have a .Value property (labels, lines, for
starters...)
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:m8********************************@4ax.com...
This is a vent because it's completely pointless to ask for. After all, VB Classic is on its way out and I probably won't even be using too much longer myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was a
WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach

Nov 13 '05 #3

P: n/a
On Sat, 27 Nov 2004 02:01:10 GMT, "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb>
wrote:

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:m8********************************@4ax.com.. .
This is a vent because it's completely pointless to ask for. After all,

VB
Classic is on its way out and I probably won't even be using too much

longer
myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was a
WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach


For *&#^$%%%!!! sake, why the F*%& not go for

WithEach In Me.Controls.acTextBox
Debug.Print .Name & "=" .Value
End WithEach


Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach

Nov 13 '05 #4

P: n/a
rkc

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:f1********************************@4ax.com...
On Sat, 27 Nov 2004 02:01:10 GMT, "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote:

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:m8********************************@4ax.com.. .
This is a vent because it's completely pointless to ask for. After all,
VB
Classic is on its way out and I probably won't even be using too much

longer
myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was

a WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach


For *&#^$%%%!!! sake, why the F*%& not go for

WithEach In Me.Controls.acTextBox
Debug.Print .Name & "=" .Value
End WithEach


Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach


Too verbose. Nobody wants to type all that.
Nov 13 '05 #5

P: n/a
On Sat, 27 Nov 2004 03:32:00 GMT, "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb>
wrote:

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:f1********************************@4ax.com.. .
On Sat, 27 Nov 2004 02:01:10 GMT, "rkc"

<rk*@yabba.dabba.do.rochester.rr.bomb>
wrote:
>
>"Steve Jorgensen" <no****@nospam.nospam> wrote in message
>news:m8********************************@4ax.com.. .
>> This is a vent because it's completely pointless to ask for. Afterall, >VB
>> Classic is on its way out and I probably won't even be using too much
>longer
>> myself.
>>
>> So anyway, here's the poinless idea - Wouldn't it be cool if there wasa >> WithEach construct?
>>
>> WithEach In Me.Controls
>> Debug.Print .Name & "=" .Value
>> End WithEach
>
>For *&#^$%%%!!! sake, why the F*%& not go for
>
> WithEach In Me.Controls.acTextBox
> Debug.Print .Name & "=" .Value
> End WithEach
>


Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach


Too verbose. Nobody wants to type all that.


Well, I was trying to invent my pie in the sky wish as a language feature, so
every library doesn't have to implement its own filtering for every case the
programmer might think up. It's more bang for the buck.
Nov 13 '05 #6

P: n/a
Steve Jorgensen wrote:
WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach


For *&#^$%%%!!! sake, why the F*%& not go for

WithEach In Me.Controls.acTextBox
Debug.Print .Name & "=" .Value
End WithEach

Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach


Shorter:

All Textbox
.ValuePair
End All

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #7

P: n/a
Steve Jorgensen wrote:
Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach


WithEach in Me.Controls Where .ControlType in (acTextBox, acComboBox, etc)

You'd have no object variable to set to nothing afterward but Would you
count on Access actually cleaning it up?

--
This sig left intentionally blank
Nov 13 '05 #8

P: n/a
On Sat, 27 Nov 2004 13:29:03 +0000, Trevor Best <no****@besty.org.uk> wrote:
Steve Jorgensen wrote:
Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach


WithEach in Me.Controls Where .ControlType in (acTextBox, acComboBox, etc)

You'd have no object variable to set to nothing afterward but Would you
count on Access actually cleaning it up?


Actually, in the case of a For loop, I know that you can't count on Access to
clean it up. I had a crashing error working with the VBIDE library trying to
figure that out.

It cleans up With virtual variables just fine, and it cleans up For Each <n>
variables just fine, but it seems to leave For Each n in <m> temporary
references (the <m>) part in scope until the end of the procedure.

I assume if we added this hypothetical feature to VBA that's not going to
happen, it would have the same bug <g>.
Nov 13 '05 #9

P: n/a

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:m8********************************@4ax.com...
This is a vent because it's completely pointless to ask for. After all,
VB
Classic is on its way out and I probably won't even be using too much
longer
myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was a
WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach


What about a function that could determine if any code anywhere in the
application was written by a moron? Something like:

Public Function FindSteve() As Boolean
'Returns True if any convoluted, garbled, inefficient, irrational, or
useless code is located.
'Look for crap here:
'//

'//

End Function
Nov 13 '05 #10

P: n/a
If you name your controls carefully (Textboxes are all txtSomething,
labels are all lblSomething, images are all imgSomething) it's easy
enough to write

for each ctl in me.controls
if ctl.name like "txt*" then
etc.

"MacDermott" <ma********@nospam.com> wrote in message news:<Fi****************@newsread3.news.atl.earthl ink.net>...
So what's wrong with
For each ctl in Me.Controls
?
Of course your code would throw errors in that loop,
because not all controls have a .Value property (labels, lines, for
starters...)
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:m8********************************@4ax.com...
This is a vent because it's completely pointless to ask for. After all,

VB
Classic is on its way out and I probably won't even be using too much

longer
myself.

So anyway, here's the poinless idea - Wouldn't it be cool if there was a
WithEach construct?

WithEach In Me.Controls
Debug.Print .Name & "=" .Value
End WithEach

Nov 13 '05 #11

P: n/a
XVMP,
Ok, if we are going to be silly, then . . . I've always wanted code &
hardware that would issue dope slaps to stupid users. Nothing injurious,
mind you, but obnoxious enough that I can get some payback for all those
help desk calls where a user insisted that debits were wrong in my software
because they were displayed with parenthesis instead of negative signs. Or
the very expensive portfolio manager at a mutual fund company that wanted me
to crack a competitors stock picking spreadsheet or the materials management
specialist that insisted cycle counting meant we should be counting bicycles
instead of Cisco routers or . . . ok I'll stop.
Anyway . . .

Public Function DetectUserIdiocy(ByVal UserIdiocyScore As Double) as long
On Error Goto Err_DopeSlapCoder

Select Case UserIdiocyScore
Case Is >= 90
DopeSlapNose
HaveComputerRemoved
Case Is >= 60 And < 90
DopeSlapForehead
ForceLogOff
LockOutLogin30Minutes
Case Is >=30 And < 60
DopeSlapCheek 'No, the g-rated cheek, stupid.
Beep Rasberry
FakeBlueScreenOfDeath
Case Else
Beep Doh
End Select

Done:
On Error Resume Next
Set UserAction = Nothing

Exit_DetectUserIdiocy:
Exit Function

Err_DopeSlapCoder:
Call CoderLocator(IssueDopeSlap)
Resume Done
End Function
"XMVP" <ac***********@hotmail.com> wrote in message
news:Cu********************@vnet-inc.com...
What about a function that could determine if any code anywhere in the
application was written by a moron? Something like:

Public Function FindSteve() As Boolean
'Returns True if any convoluted, garbled, inefficient, irrational, or
useless code is located.
'Look for crap here:
'//

'//

End Function

Nov 13 '05 #12

P: n/a
Penguin wrote:
If you name your controls carefully (Textboxes are all txtSomething,
labels are all lblSomething, images are all imgSomething) it's easy
enough to write

for each ctl in me.controls
if ctl.name like "txt*" then
etc.


I do name them like that but sometimes can forget to in a hurry, so I
use .ControlType to determine what it is, another handy tip is do
something like:

Dim ctl As TextBox
for each ctl in me.controls
if ctl.ControlType = acTextBox then
ctl.<all textbox properties drop down here>
end if
next

then go back and change the Dim to "Control", but it does require you
remember to go back and change it but then it does kind of remind you if
you don't ;-)

--
This sig left intentionally blank
Nov 13 '05 #13

P: n/a
Alan Webb wrote:
XVMP,
Ok, if we are going to be silly, then . . . I've always wanted code &
hardware that would issue dope slaps to stupid users. Nothing injurious,
mind you, but obnoxious enough that I can get some payback for all those
help desk calls where a user insisted that debits were wrong in my software
because they were displayed with parenthesis instead of negative signs. Or
the very expensive portfolio manager at a mutual fund company that wanted me
to crack a competitors stock picking spreadsheet or the materials management
specialist that insisted cycle counting meant we should be counting bicycles
instead of Cisco routers or . . . ok I'll stop.
Anyway . . .

Public Function DetectUserIdiocy(ByVal UserIdiocyScore As Double) as long
On Error Goto Err_DopeSlapCoder

Select Case UserIdiocyScore
Case Is >= 90
DopeSlapNose
HaveComputerRemoved
Case Is >= 60 And < 90
DopeSlapForehead
ForceLogOff
LockOutLogin30Minutes
Case Is >=30 And < 60
DopeSlapCheek 'No, the g-rated cheek, stupid.
Beep Rasberry
FakeBlueScreenOfDeath
Case Else
Beep Doh
End Select


You've missed the classic dopeslap back of the head best done with palm
turned 45 degrees and a movement upwards around a 11 degree offset. Then
there are some users who require a good bitch-slapping.

http://www.urbandictionary.com/defin...=Dope+Slap&f=1

--
This sig left intentionally blank
Nov 13 '05 #14

P: n/a
Steve Jorgensen <no****@nospam.nospam> wrote in
news:kn********************************@4ax.com:
On Sat, 27 Nov 2004 13:29:03 +0000, Trevor Best
<no****@besty.org.uk> wrote:
Steve Jorgensen wrote:
Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach


WithEach in Me.Controls Where .ControlType in (acTextBox,
acComboBox, etc)

You'd have no object variable to set to nothing afterward but
Would you count on Access actually cleaning it up?


Actually, in the case of a For loop, I know that you can't count
on Access to clean it up. I had a crashing error working with the
VBIDE library trying to figure that out.

It cleans up With virtual variables just fine, and it cleans up
For Each <n> variables just fine, but it seems to leave For Each n
in <m> temporary references (the <m>) part in scope until the end
of the procedure.

I assume if we added this hypothetical feature to VBA that's not
going to happen, it would have the same bug <g>.


MichKa advised that For Each constructs should have a Set variable =
Nothing after the end of the loop, because otherwise you could have
*one* implicit reference open at the end of the loop.

I can't quite figure out how there could be more than one implicit
reference hanging, since For Each uses a single variable.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #15

P: n/a
On Sun, 28 Nov 2004 18:17:02 GMT, "David W. Fenton"
<dX********@bway.net.invalid> wrote:
Steve Jorgensen <no****@nospam.nospam> wrote in
news:kn********************************@4ax.com :
On Sat, 27 Nov 2004 13:29:03 +0000, Trevor Best
<no****@besty.org.uk> wrote:
Steve Jorgensen wrote:
Wait - how about...

WithEach In Me.Controls Where .ControlType = acTextBox
Debug.Print .Name & "=" .Value
End WithEach

WithEach in Me.Controls Where .ControlType in (acTextBox,
acComboBox, etc)

You'd have no object variable to set to nothing afterward but
Would you count on Access actually cleaning it up?


Actually, in the case of a For loop, I know that you can't count
on Access to clean it up. I had a crashing error working with the
VBIDE library trying to figure that out.

It cleans up With virtual variables just fine, and it cleans up
For Each <n> variables just fine, but it seems to leave For Each n
in <m> temporary references (the <m>) part in scope until the end
of the procedure.

I assume if we added this hypothetical feature to VBA that's not
going to happen, it would have the same bug <g>.


MichKa advised that For Each constructs should have a Set variable =
Nothing after the end of the loop, because otherwise you could have
*one* implicit reference open at the end of the loop.

I can't quite figure out how there could be more than one implicit
reference hanging, since For Each uses a single variable.


Whenever I check the for each <n> object variable after the loop, it is
Nothing (in Access 2000 and 2002), so that seems to be fine.

On the other hand, if I say For Each vbc In
appOtherApp.VBE.ActiveVBProject.VBComponents, then close the other application
in the same procedure, I sometimes get an unexpected condition error. I can
fix this by dimensioning a variable vbcs as VBComponents, setting it equal to
appOtherApp.VBE.ActiveVBProject.VBComponents, looping over it, then setting it
to Nothing after the loop, and before closing the other app.
Nov 13 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.