Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default msgbox shown twice!

Hi all,

I'm working with a textbox on a userform. As the input in the textbox exeeds
200 a msgbox apperas which warns the user. However, it is only a warning as
every value is possible..

However, when I doi want to alter the value and therefor 'empty' the textbox
the msgbox appears again! How can I prevent this from happening?

Please find my code below...

any help is appreaciated!

Arjan Bregman
the Netherlands


__________________________________________________ _______________

Private Sub TextBox5_Change()
Dim planklengte19x100 As String

'hier wordt de breedte bepaald van de zelfbouwpallet is en deze waarde
wordt in "PALLET PRINT" gezet..

If TextBox5.Value <= 200 And TextBox5.Value 0 Then
planklengte19x100 = TextBox5.Value
Sheets("PALLETDATA").Range("D10") = planklengte19x100

Else
MsgBox "Let op: de ingevoerde breedte is meer dan 2.00 meter!",
vbQuestion, "Correct ingevoerd?"

End If

End Sub
__________________________________________________ ________________



--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default msgbox shown twice!

How can I prevent this from happening?

When your code changes the value in the textbox it causes the change event
code to be called. So you must set a flag so your code does not re-run:

Dim InUse As Boolean

Private Sub TextBox5_Change()
If Not InUse Then
InUse = True
TextBox5.Value = ""
InUse = False
End If
End Sub

You may be changing the value of the text box in another sub but the same
principle applies.

--
Jim
"Arjan" wrote in message
...
| Hi all,
|
| I'm working with a textbox on a userform. As the input in the textbox
exeeds
| 200 a msgbox apperas which warns the user. However, it is only a warning
as
| every value is possible..
|
| However, when I doi want to alter the value and therefor 'empty' the
textbox
| the msgbox appears again! How can I prevent this from happening?
|
| Please find my code below...
|
| any help is appreaciated!
|
| Arjan Bregman
| the Netherlands
|
|
| __________________________________________________ _______________
|
| Private Sub TextBox5_Change()
| Dim planklengte19x100 As String
|
| 'hier wordt de breedte bepaald van de zelfbouwpallet is en deze waarde
| wordt in "PALLET PRINT" gezet..
|
| If TextBox5.Value <= 200 And TextBox5.Value 0 Then
| planklengte19x100 = TextBox5.Value
| Sheets("PALLETDATA").Range("D10") = planklengte19x100
|
| Else
| MsgBox "Let op: de ingevoerde breedte is meer dan 2.00 meter!",
| vbQuestion, "Correct ingevoerd?"
|
| End If
|
| End Sub
| __________________________________________________ ________________
|
|
|
| --
| Arjan Bregman
|
| *****
| the knowledge is always there, maybe hidden, but it is there..
| *****


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default msgbox shown twice!

Instead of a msgbox, have you thought about adding a label to the userform.

It might be less intrusive--give it a nice bold red font so that any warning
won't be missed.

Arjan wrote:

Hi all,

I'm working with a textbox on a userform. As the input in the textbox exeeds
200 a msgbox apperas which warns the user. However, it is only a warning as
every value is possible..

However, when I doi want to alter the value and therefor 'empty' the textbox
the msgbox appears again! How can I prevent this from happening?

Please find my code below...

any help is appreaciated!

Arjan Bregman
the Netherlands

__________________________________________________ _______________

Private Sub TextBox5_Change()
Dim planklengte19x100 As String

'hier wordt de breedte bepaald van de zelfbouwpallet is en deze waarde
wordt in "PALLET PRINT" gezet..

If TextBox5.Value <= 200 And TextBox5.Value 0 Then
planklengte19x100 = TextBox5.Value
Sheets("PALLETDATA").Range("D10") = planklengte19x100

Else
MsgBox "Let op: de ingevoerde breedte is meer dan 2.00 meter!",
vbQuestion, "Correct ingevoerd?"

End If

End Sub
__________________________________________________ ________________

--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default msgbox shown twice!

Jim,

thnx for the reply. However, I can't get it to work properly..
how should your code look like in combination with mine?

Arjan



"Jim Rech" wrote:

How can I prevent this from happening?


When your code changes the value in the textbox it causes the change event
code to be called. So you must set a flag so your code does not re-run:

Dim InUse As Boolean

Private Sub TextBox5_Change()
If Not InUse Then
InUse = True
TextBox5.Value = ""
InUse = False
End If
End Sub

You may be changing the value of the text box in another sub but the same
principle applies.

--
Jim
"Arjan" wrote in message
...
| Hi all,
|
| I'm working with a textbox on a userform. As the input in the textbox
exeeds
| 200 a msgbox apperas which warns the user. However, it is only a warning
as
| every value is possible..
|
| However, when I doi want to alter the value and therefor 'empty' the
textbox
| the msgbox appears again! How can I prevent this from happening?
|
| Please find my code below...
|
| any help is appreaciated!
|
| Arjan Bregman
| the Netherlands
|
|
| __________________________________________________ _______________
|
| Private Sub TextBox5_Change()
| Dim planklengte19x100 As String
|
| 'hier wordt de breedte bepaald van de zelfbouwpallet is en deze waarde
| wordt in "PALLET PRINT" gezet..
|
| If TextBox5.Value <= 200 And TextBox5.Value 0 Then
| planklengte19x100 = TextBox5.Value
| Sheets("PALLETDATA").Range("D10") = planklengte19x100
|
| Else
| MsgBox "Let op: de ingevoerde breedte is meer dan 2.00 meter!",
| vbQuestion, "Correct ingevoerd?"
|
| End If
|
| End Sub
| __________________________________________________ ________________
|
|
|
| --
| Arjan Bregman
|
| *****
| the knowledge is always there, maybe hidden, but it is there..
| *****



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
I don't need the actual value but what is shown Benny Excel Discussion (Misc queries) 2 October 28th 09 01:45 PM
Convert 29.08 hours (shown in decimal form) to time shown in "hh:m Nila in Florida Excel Worksheet Functions 1 September 14th 08 01:35 AM
Column of Text Shown = Total Times Shown? philcassell Excel Worksheet Functions 3 July 19th 06 07:24 AM
Formula bar and name box not shown Marysue New Users to Excel 2 May 9th 06 09:08 PM
Named Ranges shown (or not shown) as blue means what? wdeleo Excel Worksheet Functions 0 July 8th 05 01:40 PM


All times are GMT +1. The time now is 10:47 AM.

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

About Us

"It's about Microsoft Excel"