Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default setfocus after a msgbox


exit subroutine.... you know what ... i think i am going at this th
wrong way...
i should really check for mouse or key events then validate the entry.

what do you propose?

Thank

--
simpleMo
-----------------------------------------------------------------------
simpleMod's Profile: http://www.excelforum.com/member.php...fo&userid=1572
View this thread: http://www.excelforum.com/showthread.php?threadid=27245

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default setfocus after a msgbox

Yes, I get it there too.

Personally, I avoid the Exit event, too problematical, and better to trap
input, like this

Private Sub BoxWeightTextBox_KeyPress(ByVal KeyAscii As _
MSForms.ReturnInteger)
Select Case True
Case KeyAscii = Asc("0"): 'OK
Case KeyAscii <= Asc("9"): 'OK
Case ".": 'OK
Case Else: Interaction.Beep
KeyAscii = 0
End Select
End Sub

You can also add bound checking at the end like this

Private Sub BoxWeightTextBox_BeforeUpdate(ByVal Cancel As _
MSForms.ReturnBoolean)
With BoxWeightTextBox
If CDbl(.Text) < 1 Or CDbl(.Text) 100 Then
MsgBox "Value must be Int between 1 and 100."
.SelStart = 0
.SelLength = Len(.Text)
Cancel = True
End If
End With
End Sub


--

HTH

RP

"simpleMod" wrote in message
...

exit subroutine.... you know what ... i think i am going at this the
wrong way...
i should really check for mouse or key events then validate the entry.

what do you propose?

Thanks


--
simpleMod
------------------------------------------------------------------------
simpleMod's Profile:

http://www.excelforum.com/member.php...o&userid=15724
View this thread: http://www.excelforum.com/showthread...hreadid=272454



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SetFocus on a different sheet in VBA AaronC Excel Discussion (Misc queries) 1 June 9th 05 11:18 PM
setfocus after a msgbox simpleMod Excel Programming 1 October 26th 04 04:35 PM
SetFocus Question Sam Excel Programming 2 August 20th 04 04:01 PM
SetFocus Problems Zane Greer Excel Programming 1 September 20th 03 02:26 PM
SetFocus method in VBA Robin S. Excel Programming 2 July 16th 03 10:20 PM


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"